platform/upstream/llvm.git
3 years agoSimplify a .mailmap entry
Nico Weber [Sat, 14 Aug 2021 21:58:21 +0000 (17:58 -0400)]
Simplify a .mailmap entry

Only one person committed with these email addresses, so there's no need to use
the map-different-names-for-one-email-address syntax.

No behavior change.

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

3 years ago[InstCombine] Extend sadd.sat tests to include min/max patterns. NFC
David Green [Sat, 14 Aug 2021 21:48:10 +0000 (22:48 +0100)]
[InstCombine] Extend sadd.sat tests to include min/max patterns. NFC

This tests code starting from smin/smax, as opposed to the icmp/select
form. Also adds a ARM MVE phase ordering test for vectorizing to
sadd.sat from the original IR.

3 years ago[MLIR] Move TestDialect to ::test namespace
Stephen Neuendorffer [Thu, 24 Sep 2020 18:54:46 +0000 (11:54 -0700)]
[MLIR] Move TestDialect to ::test namespace

While the changes are extensive, they basically fall into a few
categories:
1) Moving the TestDialect itself.
2) Updating C++ code in tablegen to explicitly use ::mlir, since it
will be put in a headers that shouldn't expect a 'using'.
3) Updating some generic MLIR Interface definitions to do the same thing.
4) Updating the Tablegen generator in a few places to be explicit about
namespaces
5) Doing the same thing for llvm references, since we no longer pick
up the definitions from mlir/Support/LLVM.h

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

3 years ago[Tests] Remove explicit -enable-mssa-loop-dependency options (NFC)
Nikita Popov [Sat, 14 Aug 2021 18:54:19 +0000 (20:54 +0200)]
[Tests] Remove explicit -enable-mssa-loop-dependency options (NFC)

This is enabled by default. Drop explicit uses in preparation for
removing the option.

Also drop RUN lines that are now the same (typically modulo a
-verify-memoryssa option).

3 years ago[JITLink] Unify x86-64 MachO and ELF 's optimize GOT/Stub function
luxufan [Sat, 14 Aug 2021 16:30:42 +0000 (00:30 +0800)]
[JITLink] Unify x86-64 MachO and ELF 's optimize GOT/Stub function

This patch  unify optimizeELF_x86_64_GOTAndStubs and optimizeMachO_x86_64_GOTAndStubs into a pure optimize_x86_64_GOTAndStubs

Reviewed By: lhames

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

3 years ago[Aarch64] Remove redundant c_str (NFC)
Kazu Hirata [Sat, 14 Aug 2021 15:49:40 +0000 (08:49 -0700)]
[Aarch64] Remove redundant c_str (NFC)

Identified with readability-redundant-string-cstr.

3 years ago[clang-format] Distinguish K&R C function definition and attribute
Owen [Thu, 12 Aug 2021 13:12:25 +0000 (06:12 -0700)]
[clang-format] Distinguish K&R C function definition and attribute

This is a follow-up to https://reviews.llvm.org/D107950 which
missed user-defined types in K&R C.

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

3 years ago[LoopIdiom] let the pass deal with runtime memset size
eopXD [Sat, 14 Aug 2021 07:58:05 +0000 (15:58 +0800)]
[LoopIdiom] let the pass deal with runtime memset size

The current LIR does not deal with runtime-determined memset-size. This patch
utilizes SCEV and check if the PointerStrideSCEV and the MemsetSizeSCEV are equal.
Before comparison the pass would try to fold the expression that is already
protected by the loop guard.

Testcase file `memset-runtime.ll`, `memset-runtime-debug.ll` added.

This patch deals with proper loop-idiom. Proceeding patch wants to deal with SCEV-s
that are inequal after folding with the loop guards.

Reviewed By: lebedev.ri, Whitney

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

3 years ago[clang-tidy] [PR50069] readability-braces-around-statements doesn't work well with...
mydeveloperday [Sat, 14 Aug 2021 11:05:21 +0000 (12:05 +0100)]
[clang-tidy] [PR50069] readability-braces-around-statements doesn't work well with [[likely]] [[unlikely]]

https://bugs.llvm.org/show_bug.cgi?id=50069

When clang-tidy sees:

```
if (true) [[unlikely]] {
    ...
}
```

It thinks the braces are missing and add them again.

```
if (true)  { [[unlikely]] {
    ...
  }
}
```

This revision aims to prevent that incorrect code generation

Reviewed By: aaron.ballman

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

3 years ago[clang-format] NFC update the ClangFormatStyleOption.rst following previous change
mydeveloperday [Sat, 14 Aug 2021 09:29:07 +0000 (10:29 +0100)]
[clang-format] NFC update the ClangFormatStyleOption.rst following previous change

clang/docs/tool/dump_format_style.py was not run as part of  {D99840}

Bring ClangFormatStyleOptions.rst back in line.

Reviewed By: HazardyKnusperkeks

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

3 years ago[NFC][DSE] Clean up KnownNoReads and MemorySSAScanLimit in DSE
Dawid Jurczak [Tue, 10 Aug 2021 10:56:44 +0000 (12:56 +0200)]
[NFC][DSE] Clean up KnownNoReads and MemorySSAScanLimit in DSE

Another simple cleanups set in DSE. CheckCache is removed since 1f1145006b32 and in consequence KnownNoReads is useless.
Also update description of MemorySSAScanLimit which default value is 150 instead 100.

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

3 years ago[JITLink][x86-64] Rename *Relaxable edges to *REXRelaxable.
Lang Hames [Sat, 14 Aug 2021 08:27:16 +0000 (18:27 +1000)]
[JITLink][x86-64] Rename *Relaxable edges to *REXRelaxable.

The existing relaxable edges all assume a REX prefix. ELF includes non-REX
relaxations, so rename these edges to make room for the new kinds.

3 years ago[JITLink][x86-64] Rename BranchPCRel32ToPtrJumpStub(Relaxable -> Bypassable).
Lang Hames [Sat, 14 Aug 2021 07:49:31 +0000 (17:49 +1000)]
[JITLink][x86-64] Rename BranchPCRel32ToPtrJumpStub(Relaxable -> Bypassable).

ELF allows for branch optimizations other than bypass, so rename this edge kind
to avoid any confusion.

3 years agoRevert "[Remarks] Emit optimization remarks for atomics generating CAS loop"
Anshil Gandhi [Sat, 14 Aug 2021 05:58:04 +0000 (23:58 -0600)]
Revert "[Remarks] Emit optimization remarks for atomics generating CAS loop"

This reverts commit c4e5425aa579d21530ef1766d7144b38a347f247.

3 years ago[Remarks] Emit optimization remarks for atomics generating CAS loop
Anshil Gandhi [Fri, 13 Aug 2021 22:32:02 +0000 (16:32 -0600)]
[Remarks] Emit optimization remarks for atomics generating CAS loop

Implements ORE in AtomicExpandPass to report atomics generating a compare
and swap loop.

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

3 years ago[clang-tidy] fix duplicate '{}' in cppcoreguidelines-pro-type-member-init
liuke [Sat, 14 Aug 2021 02:47:27 +0000 (10:47 +0800)]
[clang-tidy] fix duplicate '{}' in cppcoreguidelines-pro-type-member-init

The overload of the constructor will repeatedly fix the member variables that need to be initialized.
Removed the duplicate '{}'.

```
struct A {
  A() {}
  A(int) {}
  int _var;  // int _var{}{};  <--  wrong fix
};
```

Reviewed By: aaron.ballman

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

3 years agoMigrate DWARFVerifier tests to lit-based yaml instead of gtest with embedded yaml
David Blaikie [Fri, 13 Aug 2021 05:56:43 +0000 (22:56 -0700)]
Migrate DWARFVerifier tests to lit-based yaml instead of gtest with embedded yaml

Improves maintainability (edit/modify the tests without recompiling) and
error messages (previously the failure would be a gtest failure
mentioning nothing of the input or desired text) and the option to
improve tests with more checks.

(maybe these tests shouldn't all be in separate files - we could
probably have DWARF yaml that contains multiple errors while still being
fairly maintainable - the various invalid offsets (ref_addr, rnglists,
ranges, etc) could probably be all in one test, but for the simple sake
of the migration I just did the mechanical thing here)

3 years ago[GlobalISel] Narrow binops feeding into G_AND with a mask
Jessica Paquette [Wed, 11 Aug 2021 20:20:33 +0000 (13:20 -0700)]
[GlobalISel] Narrow binops feeding into G_AND with a mask

This is a fairly common pattern:

```
%mask = G_CONSTANT iN <mask val>
%add = G_ADD %lhs, %rhs
%and = G_AND %add, %mask
```

We have combines to eliminate G_AND with a mask that does nothing.

If we combined the above to this:

```
%mask = G_CONSTANT iN <mask val>
%narrow_lhs = G_TRUNC %lhs
%narrow_rhs = G_TRUNC %rhs
%narrow_add = G_ADD %narrow_lhs, %narrow_rhs
%ext = G_ZEXT %narrow_add
%and = G_AND %ext, %mask
```

We'd be able to take advantage of those combines using the trunc + zext.

For this to work (or be beneficial in the best case)

- The operation we want to narrow then widen must only be used by the G_AND
- The G_TRUNC + G_ZEXT must be free
- Performing the operation at a narrower width must not produce a different
  value than performing it at the original width *after masking.*

Example comparison between SDAG + GISel: https://godbolt.org/z/63jzb1Yvj

At -Os for AArch64, this is a 0.2% code size improvement on CTMark/pairlocalign.

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

3 years agoGlobalISel: Add helper function for getting EVT from LLT
Matt Arsenault [Sat, 31 Jul 2021 16:05:33 +0000 (12:05 -0400)]
GlobalISel: Add helper function for getting EVT from LLT

This can only give an imperfect approximation, but is enough to avoid
crashing in places where we call into EVT functions starting from LLTs.

3 years ago[RISCV] Support RISCVISD::SELECT_CC in ComputeNumSignBitsForTargetNode.
Craig Topper [Sat, 14 Aug 2021 00:39:52 +0000 (17:39 -0700)]
[RISCV] Support RISCVISD::SELECT_CC in ComputeNumSignBitsForTargetNode.

3 years agoAMDGPU: Stop attributor adding attributes to intrinsic declarations
Matt Arsenault [Thu, 12 Aug 2021 19:19:54 +0000 (15:19 -0400)]
AMDGPU: Stop attributor adding attributes to intrinsic declarations

3 years agoAMDGPU: Add indirect and extern calls to attributor test
Matt Arsenault [Wed, 11 Aug 2021 23:01:30 +0000 (19:01 -0400)]
AMDGPU: Add indirect and extern calls to attributor test

3 years agoAMDGPU: Respect compute ABI attributes with unknown OS
Matt Arsenault [Fri, 13 Aug 2021 13:20:17 +0000 (09:20 -0400)]
AMDGPU: Respect compute ABI attributes with unknown OS

Unfortunately Mesa is still using amdgcn-- as the triple for OpenGL,
so we still have the awkward unknown OS case to deal with. Previously
if the HSA ABI intrinsics appeared, we we would not add the ABI
registers to the function. We would emit an error later, but we still
need to produce some compile result. Start adding the registers to any
compute function, regardless of the OS. This keeps the internal state
more consistent, and will help avoid numerous test crashes in a future
patch which starts assuming the ABI inputs are present on functions by
default.

3 years ago[NFC] One more AttributeList::getAttribute(FunctionIndex) -> getFnAttr()
Arthur Eubanks [Fri, 13 Aug 2021 23:56:42 +0000 (16:56 -0700)]
[NFC] One more AttributeList::getAttribute(FunctionIndex) -> getFnAttr()

3 years ago[CallPromotion] Check for inalloca/byval mismatch
Arthur Eubanks [Sat, 7 Aug 2021 07:28:19 +0000 (00:28 -0700)]
[CallPromotion] Check for inalloca/byval mismatch

Previously we would allow promotion even if the byval/inalloca
attributes on the call and the callee didn't match.

It's ok if the byval/inalloca types aren't the same. For example, LTO
importing may rename types.

Fixes PR51397.

Reviewed By: rnk

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

3 years ago[NFC] One more AttributeList::getAttribute(FunctionIndex) -> getFnAttr()
Arthur Eubanks [Fri, 13 Aug 2021 23:49:05 +0000 (16:49 -0700)]
[NFC] One more AttributeList::getAttribute(FunctionIndex) -> getFnAttr()

3 years ago[NFC] Make AttributeList::hasAttribute(AttributeList::ReturnIndex) its own method
Arthur Eubanks [Fri, 13 Aug 2021 21:35:48 +0000 (14:35 -0700)]
[NFC] Make AttributeList::hasAttribute(AttributeList::ReturnIndex) its own method

AttributeList::hasAttribute() is confusing. In an attempt to change the
name to something that suggests using other methods, fix up some
existing uses.

3 years ago[NFC] Cleanup calls to AttributeList::getAttribute(FunctionIndex)
Arthur Eubanks [Fri, 13 Aug 2021 21:16:44 +0000 (14:16 -0700)]
[NFC] Cleanup calls to AttributeList::getAttribute(FunctionIndex)

getAttribute() is confusing, use a clearer method.

3 years ago[libcxx][ranges] Move `namespace views` into `namespace ranges` and add an alias.
zoecarver [Fri, 13 Aug 2021 18:36:55 +0000 (11:36 -0700)]
[libcxx][ranges] Move `namespace views` into `namespace ranges` and add an alias.

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

3 years ago[lldb] skip host build for lldb_tblgen with LLDB_TABLEGEN_EXE set
Manoj Gupta [Fri, 13 Aug 2021 20:25:14 +0000 (13:25 -0700)]
[lldb] skip host build for lldb_tblgen with LLDB_TABLEGEN_EXE set

When cross compiling lldb-server, do not create a host build
for building lldb-tblgeb when LLDB_TABLEGEN_EXE is already
provided. This avoids an expensive and time-consuming build step
if lldb-tblgen was already built previously for host.

Reviewed By: JDevlieghere

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

3 years ago[x86] add tests for fcmps with logic ops; NFC
Sanjay Patel [Fri, 13 Aug 2021 21:03:22 +0000 (17:03 -0400)]
[x86] add tests for fcmps with logic ops; NFC

3 years ago[mlir] Add support for moving reductions to outer most dimensions in vector.multi_red...
harsh-nod [Fri, 13 Aug 2021 19:54:30 +0000 (12:54 -0700)]
[mlir] Add support for moving reductions to outer most dimensions in vector.multi_reduction

The approach for handling reductions in the outer most
dimension follows that for inner most dimensions, outlined
below

First, transpose to move reduction dims, if needed
Convert reduction from n-d to 2-d canonical form
Then, for outer reductions, we emit the appropriate op
(add/mul/min/max/or/and/xor) and combine the results.

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

3 years ago[NFC] Cleanup callers of AttributeList::hasAttributes()
Arthur Eubanks [Fri, 13 Aug 2021 19:07:05 +0000 (12:07 -0700)]
[NFC] Cleanup callers of AttributeList::hasAttributes()

AttributeList::hasAttributes() is confusing, use clearer methods like
hasFnAttrs().

3 years ago[NFC] Clean up users of AttributeList::hasAttribute()
Arthur Eubanks [Fri, 13 Aug 2021 18:59:18 +0000 (11:59 -0700)]
[NFC] Clean up users of AttributeList::hasAttribute()

AttributeList::hasAttribute() is confusing, use clearer methods like
hasParamAttr()/hasRetAttr().

Add hasRetAttr() since it was missing from AttributeList.

3 years ago[NFC] Remove public uses of AttributeList::getAttributes()
Arthur Eubanks [Fri, 13 Aug 2021 18:37:26 +0000 (11:37 -0700)]
[NFC] Remove public uses of AttributeList::getAttributes()

Use methods that better convey the intent.

3 years ago[gn build] Port df324bba5c4c
LLVM GN Syncbot [Fri, 13 Aug 2021 18:34:09 +0000 (18:34 +0000)]
[gn build] Port df324bba5c4c

3 years ago[gn build] Port 7b20e05c714e
LLVM GN Syncbot [Fri, 13 Aug 2021 18:34:09 +0000 (18:34 +0000)]
[gn build] Port 7b20e05c714e

3 years ago[libcxx][ranges] Add `ranges::join_view`.
zoecarver [Fri, 6 Aug 2021 22:33:46 +0000 (15:33 -0700)]
[libcxx][ranges] Add `ranges::join_view`.

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

3 years ago[libcxx][ranges] Add `ranges::iota_view`.
zoecarver [Tue, 3 Aug 2021 20:05:20 +0000 (13:05 -0700)]
[libcxx][ranges] Add `ranges::iota_view`.

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

3 years agoAdd missed rename of getFnAttributes() -> getFnAttrs()
Arthur Eubanks [Fri, 13 Aug 2021 18:29:20 +0000 (11:29 -0700)]
Add missed rename of getFnAttributes() -> getFnAttrs()

3 years ago[NFC] Rename AttributeList::getParam/Ret/FnAttributes() -> get*Attributes()
Arthur Eubanks [Fri, 13 Aug 2021 18:16:52 +0000 (11:16 -0700)]
[NFC] Rename AttributeList::getParam/Ret/FnAttributes() -> get*Attributes()

This is more consistent with similar methods.

3 years ago[NFC] Rename AttributeList::hasFnAttribute() -> hasFnAttr()
Arthur Eubanks [Fri, 13 Aug 2021 18:09:18 +0000 (11:09 -0700)]
[NFC] Rename AttributeList::hasFnAttribute() -> hasFnAttr()

This is more consistent with similar methods.

3 years ago[NFC] Remove AttributeList::hasParamAttribute()
Arthur Eubanks [Fri, 13 Aug 2021 17:57:15 +0000 (10:57 -0700)]
[NFC] Remove AttributeList::hasParamAttribute()

It's the same as AttributeList::hasParamAttr().

3 years ago[Polly] Rename CodeGen -> generateCode. NFC.
Michael Kruse [Fri, 13 Aug 2021 17:39:23 +0000 (12:39 -0500)]
[Polly] Rename CodeGen -> generateCode. NFC.

To conform to function naming convention: camelCase and start with a
verb.

3 years ago[Polly] Decompose object construction and detection algorithm. NFC.
Michael Kruse [Fri, 13 Aug 2021 17:26:35 +0000 (12:26 -0500)]
[Polly] Decompose object construction and detection algorithm. NFC.

Avoid doing the detection work inside the constructor. In addition to
polymorphism being unintuitive in constructors and other design problems
such as if an exception is thrown, the ScopDetection class is usable
without detection in the sense of "no Scop found" or "function skipped".

3 years ago[PowerPC] Disable CTR Loop generate for fma with the PPC double double type.
Amy Kwan [Fri, 13 Aug 2021 16:22:38 +0000 (11:22 -0500)]
[PowerPC] Disable CTR Loop generate for fma with the PPC double double type.

It is possible to generate the llvm.fmuladd.ppcf128 intrinsic, and there is no actual
FMA instruction that corresponds to this intrinsic call for ppcf128. Thus, this
intrinsic needs to remain as a call as it cannot be lowered to any instruction, which
also means we need to disable CTR loop generation for fma involving the ppcf128 type.
This patch accomplishes this behaviour.

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

3 years ago[IFS] Fix the copy constructor warning in IFSStub.cpp
Haowei Wu [Thu, 12 Aug 2021 21:33:47 +0000 (14:33 -0700)]
[IFS] Fix the copy constructor warning in IFSStub.cpp

This change fixes the gcc warning on copy constructor in IFSStub.cpp
file.

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

3 years ago[Flang] Fix for CI failure, Remove default case
Kiran Chandramohan [Fri, 13 Aug 2021 17:05:35 +0000 (18:05 +0100)]
[Flang] Fix for CI failure, Remove default case

Remove default case when all the enum values are covered in switch
statements.

3 years ago[sanitizer_common] disable format errors.
Florian Mayer [Fri, 13 Aug 2021 15:24:11 +0000 (16:24 +0100)]
[sanitizer_common] disable format errors.

This broke https://lab.llvm.org/buildbot/#/builders/37/builds/6061/steps/32/logs/stdio

Reviewed By: dvyukov

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

3 years ago[Clang] Add an explicit makeArrayRef to appease gcc 5.4.
Craig Topper [Fri, 13 Aug 2021 16:42:06 +0000 (09:42 -0700)]
[Clang] Add an explicit makeArrayRef to appease gcc 5.4.

3 years ago[X86] Add parentheses around casts in some of the X86 intrinsic headers.
Craig Topper [Fri, 13 Aug 2021 16:22:43 +0000 (09:22 -0700)]
[X86] Add parentheses around casts in some of the X86 intrinsic headers.

This covers the SSE and AVX/AVX2 headers. AVX512 has a lot more macros
due to rounding mode.

Fixes part of PR51324.

Reviewed By: pengfei

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

3 years ago[AsmWriter][NFC] Simplify writeDIGenericSubrange
Alfonso Gregory [Fri, 13 Aug 2021 16:31:13 +0000 (09:31 -0700)]
[AsmWriter][NFC] Simplify writeDIGenericSubrange

Reviewed By: MaskRay

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

3 years ago[AArch64][GlobalISel] Legalize scalar G_SSUBSAT + G_SADDSAT
Jessica Paquette [Mon, 9 Aug 2021 18:41:52 +0000 (11:41 -0700)]
[AArch64][GlobalISel] Legalize scalar G_SSUBSAT + G_SADDSAT

These are lowered, matching SDAG behaviour. (See
llvm/test/CodeGen/AArch64/ssub_sat.ll and llvm/test/CodeGen/AArch64/sadd_sat.ll)

These fall back ~159 times on a build of clang with GISel enabled.

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

3 years ago[MLIR][Linalg] Fix typo
Lorenzo Chelini [Fri, 13 Aug 2021 16:00:14 +0000 (18:00 +0200)]
[MLIR][Linalg] Fix typo

3 years agotsan/dd: fix format strings
Dmitry Vyukov [Fri, 13 Aug 2021 15:16:27 +0000 (17:16 +0200)]
tsan/dd: fix format strings

Reviewed By: melver

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

3 years agoRevert "[clang-format] Distinguish K&R C function definition and attribute"
David Spickett [Fri, 13 Aug 2021 15:25:32 +0000 (16:25 +0100)]
Revert "[clang-format] Distinguish K&R C function definition and attribute"

This reverts commit de763c4037157e60551ba227ccd0ed02e109c317.

Causing test failures on the Arm/AArch64 quick bots:
https://lab.llvm.org/buildbot/#/builders/188/builds/2202

3 years agoFix bad assert in print-changed code
Jamie Schmeiser [Fri, 13 Aug 2021 14:53:24 +0000 (10:53 -0400)]
Fix bad assert in print-changed code

Summary:
The assertion that both functions were not missing was incorrect and would
fail when one of the functions was missing. Fixed it and moved the
assertion earlier to check the input parameters to better capture
first-failure.  Added lit test.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks)
Differential Revision: https://reviews.llvm.org/D107989

3 years agoRevert "[SCEV] Remove premature assert. PR46786"
Roman Lebedev [Fri, 13 Aug 2021 14:38:36 +0000 (17:38 +0300)]
Revert "[SCEV] Remove premature assert. PR46786"

Since then, the SCEV pointer handling as been improved,
so the assertion should now hold.

This reverts commit b96114c1e1fc4448ea966bce013706359aee3fa9,
relanding the assertion from commit 141e845da5dda6743a09f858b4aec0133a931453.

3 years ago[flang][OpenMP] Add semantic check for teams nesting
Peixin Qiao [Fri, 13 Aug 2021 14:20:38 +0000 (10:20 -0400)]
[flang][OpenMP] Add semantic check for teams nesting

This patch implements the following check for TEAMS construct:
```
OpenMP Version 5.0 Teams construct restriction: A teams region can
only be strictly nested within the implicit parallel region or a target
region. If a teams construct is nested within a target construct, that
target construct must contain no statements, declarations or directives
outside of the teams construct.
```

Also add one test case for the check.

Reviewed By: kiranchandramohan, clementval

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

3 years agotsan: fix latent bug in shadow computation
Dmitry Vyukov [Fri, 13 Aug 2021 13:24:23 +0000 (15:24 +0200)]
tsan: fix latent bug in shadow computation

We use kShadowCnt (number of shadow cells per application granule)
when computing shadow, but it's wrong. We need the ratio
between shadow and app memory (how much shadow is larger than app memory),
which is kShadowMultiplier.
Currently both are equal to 4, so it works fine.
Use the correct constant.

Reviewed By: melver

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

3 years ago[analyzer][NFC] Make test/Analysis/self-assign.cpp readable
Kristóf Umann [Fri, 13 Aug 2021 13:46:32 +0000 (15:46 +0200)]
[analyzer][NFC] Make test/Analysis/self-assign.cpp readable

3 years ago[flang][OpenMP] Add semantic checks for cancellation nesting
Peixin Qiao [Fri, 13 Aug 2021 12:19:01 +0000 (08:19 -0400)]
[flang][OpenMP] Add semantic checks for cancellation nesting

This patch implements the following semantic checks for cancellation constructs:
```
OpenMP Version 5.0 Section 2.18.1: CANCEL construct restriction:
If construct-type-clause is taskgroup, the cancel construct must be
closely nested inside a task or a taskloop construct and the cancel
region must be closely nested inside a taskgroup region. If
construct-type-clause is sections, the cancel construct must be closely
nested inside a sections or section construct. Otherwise, the cancel
construct must be closely nested inside an OpenMP construct that matches
the type specified in construct-type-clause of the cancel construct.

OpenMP Version 5.0 Section 2.18.2: CANCELLATION POINT restriction:
A cancellation point construct for which construct-type-clause is
taskgroup must be closely nested inside a task or taskloop construct,
and the cancellation point region must be closely nested inside a
taskgroup region. A cancellation point construct for which
construct-type-clause is sections must be closely nested inside a
sections or section construct. A cancellation point construct for which
construct-type-clause is neither sections nor taskgroup must be closely
nested inside an OpenMP construct that matches the type specified in
construct-type-clause.
```

Also add test cases for the check.

Reviewed By: kiranchandramohan

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

3 years ago[NFC] Drop idle compiler option from the test.
Alexey Bader [Fri, 13 Aug 2021 06:04:09 +0000 (09:04 +0300)]
[NFC] Drop idle compiler option from the test.

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

3 years ago[OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.
Justas Janickas [Fri, 6 Aug 2021 12:50:13 +0000 (13:50 +0100)]
[OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.

Some Clang diagnostics could only report OpenCL C version. Because
C++ for OpenCL can be used as an alternative to OpenCL C, the text
for diagnostics should reflect that.

Desrciptions modified for these diagnostics:
`err_opencl_unknown_type_specifier`
`warn_option_invalid_ocl_version`
`err_attribute_requires_opencl_version`
`warn_opencl_attr_deprecated_ignored`
`ext_opencl_ext_vector_type_rgba_selector`

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

3 years agoReland "[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautologi...
Roman Lebedev [Fri, 13 Aug 2021 12:08:10 +0000 (15:08 +0300)]
Reland "[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological""

The commit originally unearthed a problem, reported as
https://reviews.llvm.org/rGf30a7dff8a5b32919951dcbf92e4a9d56c4679ff#1019890
Now that the problem has been fixed, and the assertion no longer fires,
let's see if there are other cases it fires on.

This reverts commit 5c8c24d2decae4a76047777271d60411fc3316eb,
relanding commit f30a7dff8a5b32919951dcbf92e4a9d56c4679ff.

3 years ago[SimplifyCFG] Restart if `removeUndefIntroducingPredecessor()` made changes
Roman Lebedev [Fri, 13 Aug 2021 12:35:01 +0000 (15:35 +0300)]
[SimplifyCFG] Restart if `removeUndefIntroducingPredecessor()` made changes

It might changed the condition of a branch into a constant,
so we should restart and constant-fold terminator,
instead of continuing with the tautological "conditional" branch.
This fixes the issue reported at https://reviews.llvm.org/rGf30a7dff8a5b32919951dcbf92e4a9d56c4679ff

3 years ago[NFC][SimplifyCFG] Add test for failed assertion
Roman Lebedev [Fri, 13 Aug 2021 12:08:00 +0000 (15:08 +0300)]
[NFC][SimplifyCFG] Add test for failed assertion

This would trigger an assertion that was added in rGf30a7dff8a5b.
Need to fix that before relanding.

Reduced from https://reviews.llvm.org/rGf30a7dff8a5b#1019890

3 years ago[MC][ELF] Mark Solaris objects as ELFOSABI_SOLARIS
Rainer Orth [Fri, 13 Aug 2021 12:31:32 +0000 (14:31 +0200)]
[MC][ELF] Mark Solaris objects as ELFOSABI_SOLARIS

Prompted by D107747 <https://reviews.llvm.org/D107747>, it seems prudent to
mark objects as `ELFOSABI_SOLARIS` on Solaris.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

3 years ago[clang-format] Distinguish K&R C function definition and attribute
Owen [Thu, 12 Aug 2021 13:12:25 +0000 (06:12 -0700)]
[clang-format] Distinguish K&R C function definition and attribute

This is a follow-up to https://reviews.llvm.org/D107950 which
missed user-defined types in K&R C.

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

3 years ago[mlir] Remove unused header include.
Adrian Kuegel [Fri, 13 Aug 2021 11:43:58 +0000 (13:43 +0200)]
[mlir] Remove unused header include.

Also adjust BUILD.bazel and remove an unused dependency.

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

3 years agoscudo/standalone: prepare for enabling format string checking
Dmitry Vyukov [Fri, 13 Aug 2021 05:29:41 +0000 (07:29 +0200)]
scudo/standalone: prepare for enabling format string checking

Move __attribute__((format)) to the function declarations in the header file.
It's almost pointless in the source file.
But disable the warning  with -Wno-format for now
since there is a number of existing warnings.

Depends on D107984.

Reviewed By: vitalybuka

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

3 years agoubsan: fix few format string bugs
Dmitry Vyukov [Thu, 12 Aug 2021 18:00:16 +0000 (20:00 +0200)]
ubsan: fix few format string bugs

This fixes just a few of the warnings.
Ubsan is not completely clean yet,
but these somehow pop up while I was
fixing other sanitizers.

Depends on D107983.

Reviewed By: vitalybuka

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

3 years agotsan: clean up and enable format string checking
Dmitry Vyukov [Thu, 12 Aug 2021 17:57:31 +0000 (19:57 +0200)]
tsan: clean up and enable format string checking

Depends on D107982.

Reviewed By: vitalybuka

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

3 years agomsan: clean up and enable format string checking
Dmitry Vyukov [Thu, 12 Aug 2021 17:55:59 +0000 (19:55 +0200)]
msan: clean up and enable format string checking

Depends on D107981.

Reviewed By: vitalybuka

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

3 years agosanitizer_common: enable format string checking
Dmitry Vyukov [Thu, 12 Aug 2021 17:52:24 +0000 (19:52 +0200)]
sanitizer_common: enable format string checking

Enable -Wformat in sanitizer_common now that it's
cleaned up from existing warnings.
But disable it in all sanitizers for now since
they are not cleaned up yet, but inherit sanitizer_common CFLAGS.

Depends on D107980.

Reviewed By: vitalybuka

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

3 years agosanitizer_common: fix format strings
Dmitry Vyukov [Thu, 12 Aug 2021 17:47:23 +0000 (19:47 +0200)]
sanitizer_common: fix format strings

Fix existing -Wformat warnings.

Depends on D107979.

Reviewed By: vitalybuka

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

3 years agosanitizer_common: declare vars more locally in VSNPrintf
Dmitry Vyukov [Fri, 13 Aug 2021 05:36:56 +0000 (07:36 +0200)]
sanitizer_common: declare vars more locally in VSNPrintf

No point in declaring variables separately before use.

Depends on D107979.

Reviewed By: vitalybuka

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

3 years agoRevert "sanitizer_common: support printing __m128i type"
Dmitry Vyukov [Thu, 12 Aug 2021 18:07:05 +0000 (20:07 +0200)]
Revert "sanitizer_common: support printing __m128i type"

This reverts commits
"sanitizer_common: support printing __m128i type"
and "[sanitizer] Fix VSNPrintf %V on Windows".

Unfortunately, custom "%V" is inherently incompatible with -Wformat,
it produces both:
warning: invalid conversion specifier 'V' [-Wformat-invalid-specifier]
warning: data argument not used by format string [-Wformat-extra-args]
If we disable both of these warnings we lose lots of useful warnings as well.

Depends on D107978.

Reviewed By: vitalybuka

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

3 years agoscudo: fix __attribute__((format))
Dmitry Vyukov [Thu, 12 Aug 2021 17:59:12 +0000 (19:59 +0200)]
scudo: fix __attribute__((format))

The attribute should be in the header on declaration.
It's almost pointless in the source file.

Depends on D107977.

Reviewed By: vitalybuka

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

3 years agosanitizer_common: prepare for enabling format string checking
Dmitry Vyukov [Thu, 12 Aug 2021 17:37:29 +0000 (19:37 +0200)]
sanitizer_common: prepare for enabling format string checking

The __attribute__((format)) was added somewhere in 2012,
the lost during refactoring, then re-added in 2014 but
to te source files, which is a no-op.
Move it back to header files so that it actually takes effect.
But over the past 7 years we've accumulated whole lot of
format string bugs of different types, so disable the warning
with -Wno-format for now for incremental clean up.

Among the bugs that it warns about are all kinds of bad things:
 - wrong sizes of arguments
 - missing/excessive arguments
 - printing wrong things (e.g. *ptr instead of ptr)
 - completely messed up format strings
 - security issues where external string is used as format

Reviewed By: vitalybuka

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

3 years ago[hwasan] Fix wild free tests on x86.
Florian Mayer [Fri, 13 Aug 2021 10:50:52 +0000 (11:50 +0100)]
[hwasan] Fix wild free tests on x86.

3 years ago[clang][deps] Move `SingleCommandCompilationDatabase` to a header
Jan Svoboda [Fri, 13 Aug 2021 10:48:14 +0000 (12:48 +0200)]
[clang][deps] Move `SingleCommandCompilationDatabase` to a header

This makes `SingleCommandCompilationDatabase` reusable.

3 years agoRevert "[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological"
Roman Lebedev [Fri, 13 Aug 2021 10:15:24 +0000 (13:15 +0300)]
Revert "[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological"

The assertion does not hold on a provided reproducer.
Reverting until after fixing the problem.

This reverts commit f30a7dff8a5b32919951dcbf92e4a9d56c4679ff.

3 years ago[SVE] Add folds for truncation of vscale
Dylan Fleming [Fri, 13 Aug 2021 08:36:31 +0000 (09:36 +0100)]
[SVE] Add folds for truncation of vscale

Reviewed By: david-arm

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

3 years ago[LoopFlatten] Fix assertion failure in checkOverflow
Rosie Sumpter [Mon, 9 Aug 2021 11:51:17 +0000 (12:51 +0100)]
[LoopFlatten] Fix assertion failure in checkOverflow

There is an assertion failure in computeOverflowForUnsignedMul
(used in checkOverflow) due to the inner and outer trip counts
having different types. This occurs when the IV has been widened,
but the loop components are not successfully rediscovered.
This is fixed by some refactoring of the code in findLoopComponents
which identifies the trip count of the loop.

3 years ago[NFC] Add commas in code comments.
Alexey Bader [Mon, 24 May 2021 08:38:16 +0000 (11:38 +0300)]
[NFC] Add commas in code comments.

3 years ago[clangd] Guard against null Attrs in the AST
Sam McCall [Fri, 13 Aug 2021 08:38:42 +0000 (10:38 +0200)]
[clangd] Guard against null Attrs in the AST

3 years ago[flang][nfc] Remove `flang-new-driver` from LIT
Andrzej Warzynski [Thu, 12 Aug 2021 19:17:39 +0000 (19:17 +0000)]
[flang][nfc] Remove `flang-new-driver` from LIT

After merging https://reviews.llvm.org/D105811, `flang-new-driver` is no
longer required.

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

3 years ago[AMDGPU][OpenMP] Use llvm-link to link ocml libraries
Pushpinder Singh [Thu, 12 Aug 2021 08:46:24 +0000 (14:16 +0530)]
[AMDGPU][OpenMP] Use llvm-link to link ocml libraries

This fixes the 'unused linker option: -lm' warning when compiling
program with -c.

Reviewed By: JonChesterfield

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

3 years ago[hwasan] Add report for wild frees.
Florian Mayer [Thu, 5 Aug 2021 16:03:09 +0000 (17:03 +0100)]
[hwasan] Add report for wild frees.

Reviewed By: eugenis

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

3 years ago[clang] Adjust BUILD.bazel file to also generate AttrDocTable.
Adrian Kuegel [Fri, 13 Aug 2021 06:22:19 +0000 (08:22 +0200)]
[clang] Adjust BUILD.bazel file to also generate AttrDocTable.

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

3 years ago[JITLink] Update ELF_x86_64 's edge kind to generic edge kind
luxufan [Fri, 13 Aug 2021 04:40:34 +0000 (12:40 +0800)]
[JITLink] Update ELF_x86_64 's edge kind to generic edge kind

This patch uses a switch statement to map the ELF_x86_64's edge kind to generic edge kind, and merge the ELF_x86_64 's applyFixup function to the x86_64 's applyFixup function. Some edge kinds were not have corresponding generic edge kinds, so I added three generic edge kinds asa follows:
1. RequestGOTAndTransformToDelta64, which is similar to RequestGOTAndTransformToDelta32.

2. GOTDelta64. This generic kind is similar to Delta64, except the GOTDelta64 computes the delta relative to GOTSymbol

3. RequestGOTAndTransformToGOTDelta64. This edge kind was used to deal with ELF_x86_64's GOT64 edge kind, it request the fixGOTEdge function to change the target to GOT entry, and set the edge kind to generic edge kind GOTDelta64.

These added generic edge kinds may named haphazardly, or can't express its meaning well.

Reviewed By: lhames

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

3 years ago[clang][Arm] Fix the default floating point ABI for
Sarah Purohit [Fri, 13 Aug 2021 04:41:35 +0000 (21:41 -0700)]
[clang][Arm] Fix the default floating point ABI for
'armv7-pc-win32-macho'

It is incorrect to select the hardware floating point ABI on Mach-O
platforms using the Windows triple if the ABI is "apcs-gnu".

rdar://81810554

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

3 years ago[AVR] Enable machine verifier
Shivam Gupta [Fri, 13 Aug 2021 04:10:39 +0000 (12:10 +0800)]
[AVR] Enable machine verifier

Reviewed By: mhjacobson, benshi001

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

3 years agoPre-commit two-way clamp tests
Qiu Chaofan [Fri, 13 Aug 2021 04:02:32 +0000 (12:02 +0800)]
Pre-commit two-way clamp tests

3 years agoAdd PowerPC AIX triple to indirect call VP testcase.
Wael Yehia [Fri, 13 Aug 2021 02:02:10 +0000 (02:02 +0000)]
Add PowerPC AIX triple to indirect call VP testcase.

3 years ago[OMPIRBuilder] Clarify CanonicalLoopInfo. NFC.
Michael Kruse [Fri, 13 Aug 2021 01:07:55 +0000 (20:07 -0500)]
[OMPIRBuilder] Clarify CanonicalLoopInfo. NFC.

Add in-source documentation on how CanonicalLoopInfo is intended to be used. In particular, clarify what parts of a CanonicalLoopInfo is considered part of the loop, that those parts must be side-effect free, and that InsertPoints to instructions outside those parts can be expected to be preserved after method calls implementing loop-associated directives.

CanonicalLoopInfo are now invalidated after it does not describe canonical loop anymore and asserts when trying to use it afterwards.

In addition, rename `createXYZWorkshareLoop` to `applyXYZWorkshareLoop` and remove the update location to avoid that the impression that they insert something from scratch at that location where in reality its InsertPoint is ignored. createStaticWorkshareLoop does not return a CanonicalLoopInfo anymore. First, it was not a canonical loop in the clarified sense (containing side-effects in form of calls to the OpenMP runtime). Second, it is ambiguous which of the two possible canonical loops it should actually return. It will not be needed before a feature expected to be introduced in OpenMP 6.0

Also see discussion in D105706.

Reviewed By: ftynse

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

3 years ago[mailmap] Add entry for the GN LLVM syncbot
Nico Weber [Fri, 13 Aug 2021 01:59:54 +0000 (21:59 -0400)]
[mailmap] Add entry for the GN LLVM syncbot

The bot did its first 43 commits under the name "GN Syncbot" before
it switched to "LLVM GN Syncbot". Use the latter as canonical name.

3 years ago[gn build] Port 2ff7ca98a99b
LLVM GN Syncbot [Fri, 13 Aug 2021 01:31:18 +0000 (01:31 +0000)]
[gn build] Port 2ff7ca98a99b

3 years ago[gn build] manually port 18f9e25ce1fa43 (AttrDocTable)
Nico Weber [Fri, 13 Aug 2021 01:29:12 +0000 (21:29 -0400)]
[gn build] manually port 18f9e25ce1fa43 (AttrDocTable)

Also clang ClangAttrEmitter for -gen-clang-attr-doc-table to be
like all other tablegen: Produce a .inc file with the generated bits
and put the static parts into a regular .cpp file that includes the
.inc file.