platform/upstream/llvm.git
3 years ago[MLIR] ODS TypeDefs: getChecked() and internal enhancements
John Demme [Mon, 19 Oct 2020 01:07:44 +0000 (01:07 +0000)]
[MLIR] ODS TypeDefs: getChecked() and internal enhancements

Have the ODS TypeDef generator write the getChecked() definition.
Also add to TypeParamCommaFormatter a `JustParams` format and
refactor around that.

Reviewed By: rriddle

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

3 years ago[X86] Sort the tables before printing in X86FoldTablesEmitter.
Craig Topper [Mon, 19 Oct 2020 00:16:14 +0000 (17:16 -0700)]
[X86] Sort the tables before printing in X86FoldTablesEmitter.

This makes diffing with the manual tables easier. And if we ever
directly use the autogenerated tables instead of the manual tables
we'll need them to be in sorted order for the binary search.

3 years ago[MLIR] ODS TypeDef documentation
John Demme [Mon, 19 Oct 2020 00:20:53 +0000 (00:20 +0000)]
[MLIR] ODS TypeDef documentation

Adds documentation for the new ODS TypeDef support.

Reviewed By: rriddle

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

3 years agoPR47893: Synthesis of a comparison operator from an 'operator<=>'
Richard Smith [Sun, 18 Oct 2020 21:15:12 +0000 (14:15 -0700)]
PR47893: Synthesis of a comparison operator from an 'operator<=>'
inherits the SFINAEness of its enclosing context.

3 years agoPR47870: Properly mangle placeholders for deduced class template
Richard Smith [Sun, 18 Oct 2020 20:52:31 +0000 (13:52 -0700)]
PR47870: Properly mangle placeholders for deduced class template
specializations that have no deduced type.

3 years ago[mlir] Add canonicalization for cond_br that feed into a cond_br on the same condition
River Riddle [Sun, 18 Oct 2020 20:43:09 +0000 (13:43 -0700)]
[mlir] Add canonicalization for cond_br that feed into a cond_br on the same condition

```
   ...
   cond_br %cond, ^bb1(...), ^bb2(...)
 ...
 ^bb1: // has single predecessor
   ...
   cond_br %cond, ^bb3(...), ^bb4(...)
```

 ->

```
   ...
   cond_br %cond, ^bb1(...), ^bb2(...)
 ...
 ^bb1: // has single predecessor
   ...
   br ^bb3(...)
```

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

3 years ago[X86] Add test cases for PR47874. NFC
Craig Topper [Sun, 18 Oct 2020 19:45:01 +0000 (12:45 -0700)]
[X86] Add test cases for PR47874. NFC

3 years ago[libc++][dsl] Run checks for locale names aliases using a single %exec
Alex Richardson [Sun, 18 Oct 2020 15:06:00 +0000 (16:06 +0100)]
[libc++][dsl] Run checks for locale names aliases using a single %exec

This changes the checking for available locales to use one program that
iterates over argv to test multiple locale names instead of checking each
name with a separate executable.

This massively speeds up running individual tests using an SSH executor
(it can take up to 10 seconds to compile and run a single test in some
emulated environments) in case no locales are installed since then all
fallback names are tested idividually. But even on a native machine
this reduces the libc++ lit startup time by ~1-2 second for me on a machine
that does not have locale data installed.

Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D88884

3 years ago[clang-format] Add a SpaceAroundPointerQualifiers style option
Alex Richardson [Sun, 18 Oct 2020 15:05:36 +0000 (16:05 +0100)]
[clang-format] Add a SpaceAroundPointerQualifiers style option

Some projects (e.g. FreeBSD) align pointers to the right but expect a
space between the '*' and any pointer qualifiers such as const. To handle
these cases this patch adds a new config option SpaceAroundPointerQualifiers
that can be used to configure whether spaces need to be added before/after
pointer qualifiers.

PointerAlignment = Right
SpaceAroundPointerQualifiers = Default/After:
void *const *x = NULL;
SpaceAroundPointerQualifiers = Before/Both
void * const *x = NULL;

PointerAlignment = Left
SpaceAroundPointerQualifiers = Default/Before:
void* const* x = NULL;
SpaceAroundPointerQualifiers = After/Both
void* const * x = NULL;

PointerAlignment = Middle
SpaceAroundPointerQualifiers = Default/Before/After/Both:
void * const * x = NULL;

Reviewed By: MyDeveloperDay

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

3 years ago[libc++] Fix aligned_alloc tests FreeBSD
Alex Richardson [Sun, 18 Oct 2020 15:05:01 +0000 (16:05 +0100)]
[libc++] Fix aligned_alloc tests FreeBSD

On FreeBSD we get the following error when passing zero as the requested
alignment: error: requested alignment is not a power of 2

Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D88820

3 years ago[NFC] Make non-modifying members const.
Mark de Wever [Sun, 18 Oct 2020 12:11:41 +0000 (14:11 +0200)]
[NFC] Make non-modifying members const.

Implementing the likelihood attributes for the iteration statements adds
a new helper function. This function can't be const qualified since
these non-modifying members aren't const qualified.

3 years ago[PowerPC][AIX] Make `__vector [un]signed long` an error
Hubert Tong [Sun, 18 Oct 2020 14:30:14 +0000 (10:30 -0400)]
[PowerPC][AIX] Make `__vector [un]signed long` an error

The semantics associated with `__vector [un]signed long` are neither
consistently specified nor consistently implemented.

The IBM XL compilers on AIX traditionally treated these as deprecated
aliases for the corresponding `__vector int` type in both 32-bit and
64-bit modes. The newer, Clang-based, IBM XL compilers on AIX make usage
of the previously deprecated types an error. This is also consistent
with IBM XL C/C++ for Linux on Power (on little endian distributions).

In line with the above, this patch upgrades (on AIX) the deprecation of
`__vector long` to become removal.

Reviewed By: ZarkoCA

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

3 years agoFix various format specifier mismatches
Hubert Tong [Sun, 18 Oct 2020 15:41:52 +0000 (11:41 -0400)]
Fix various format specifier mismatches

Format specifiers of incorrect length are replaced with format specifier
macros from `<cinttypes>` matching the typedefs used to declare the type
of the value being printed.

Reviewed By: MaskRay

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

3 years ago[test][NFC] Do ptrdiff_t comparison with signed instead of unsigned constants
Hubert Tong [Sun, 18 Oct 2020 02:22:43 +0000 (22:22 -0400)]
[test][NFC] Do ptrdiff_t comparison with signed instead of unsigned constants

... because using unsigned constants for comparing against signed values
is liable to mutate the signed value via conversion to an unsigned type
due to the usual arithmetic conversions.

3 years ago[BasicAA] Accept AATags by const reference (NFC)
Nikita Popov [Sun, 18 Oct 2020 15:34:22 +0000 (17:34 +0200)]
[BasicAA] Accept AATags by const reference (NFC)

Rather than swapping the value, the sizes, the AA tags and the
underlying objects multiple times, invoke the helper methods
with swapped arguments.

3 years ago[gn build] (manually) port d09b08919ca
Nico Weber [Sun, 18 Oct 2020 16:17:55 +0000 (12:17 -0400)]
[gn build] (manually) port d09b08919ca

3 years ago[ASAN] Restore and adjust tests
Dávid Bolvanský [Sun, 18 Oct 2020 15:28:05 +0000 (17:28 +0200)]
[ASAN] Restore and adjust tests

There are optimized out with -fno-builtin

3 years ago[NFC][clang-tidy] Use isInStdNamespace matcher instead of check defined alternatives
Nathan James [Sun, 18 Oct 2020 15:02:11 +0000 (16:02 +0100)]
[NFC][clang-tidy] Use isInStdNamespace matcher instead of check defined alternatives

3 years ago[nfc] [lldb] [testsuite] Fix DW_FORM_ref* in DW_AT_declaration-with-children.s .
Jan Kratochvil [Sun, 18 Oct 2020 14:48:47 +0000 (16:48 +0200)]
[nfc] [lldb] [testsuite] Fix DW_FORM_ref* in DW_AT_declaration-with-children.s .

There were invalid DIE references which nobody used. If LLDB starts to
report invalid DIE references it would lock up (mutex lock).

These invalid DIE references are there since initial check-in by:
  https://reviews.llvm.org/D83302

3 years ago[clang tidy] Fix SIMDIntrinsicsCheck not storing options
Nathan James [Sun, 18 Oct 2020 14:56:39 +0000 (15:56 +0100)]
[clang tidy] Fix SIMDIntrinsicsCheck not storing options

3 years ago[DSE] Do not consider 'noop' intrinsics as read-clobbers.
Florian Hahn [Sun, 18 Oct 2020 14:19:05 +0000 (15:19 +0100)]
[DSE] Do not consider 'noop' intrinsics as read-clobbers.

isNoopIntrinsic returns true for some intrinsics that are modeled in
MemorySSA but do not actually read or write any memory and do not block
DSE. Such intrinsics should not be considered as read-clobbers.

3 years ago[TableGen] Change Programmer's Reference to use "DAG argument" rather than "operand".
Paul C. Anagnostopoulos [Sat, 17 Oct 2020 14:42:26 +0000 (10:42 -0400)]
[TableGen] Change Programmer's Reference to use "DAG argument" rather than "operand".

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

3 years ago[AA] Add helper to update result (NFC)
Nikita Popov [Sun, 18 Oct 2020 14:41:44 +0000 (16:41 +0200)]
[AA] Add helper to update result (NFC)

This pattern was repeated a few times, and for some reason always
using insert or try_emplace, even though we know in advance that
we're looking for an existing entry and not trying to create a
new one.

3 years ago[DSE] Add tests for elimination at end of function with lifetime.
Florian Hahn [Sun, 18 Oct 2020 12:55:26 +0000 (13:55 +0100)]
[DSE] Add tests for elimination at end of function with lifetime.

3 years ago[Sanitizers] Remove OpenBSD support
David Carlier [Sun, 18 Oct 2020 05:01:29 +0000 (06:01 +0100)]
[Sanitizers] Remove OpenBSD support

- Removing unused and unusable code.

Reviewers: krytarowski

Reviewed By: krytarowski

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

3 years ago[LoopIdiom] Regenerate test checks; NFC
Dávid Bolvanský [Sun, 18 Oct 2020 12:06:34 +0000 (14:06 +0200)]
[LoopIdiom] Regenerate test checks; NFC

3 years ago[NFC] Fixes a documentation typo.
Mark de Wever [Sun, 18 Oct 2020 11:47:04 +0000 (13:47 +0200)]
[NFC] Fixes a documentation typo.

3 years ago[Sema, CodeGen] Implement [[likely]] and [[unlikely]] in SwitchStmt
Mark de Wever [Sun, 18 Oct 2020 11:34:41 +0000 (13:34 +0200)]
[Sema, CodeGen] Implement [[likely]] and [[unlikely]] in SwitchStmt

This implements the likelihood attribute for the switch statement. Based on the
discussion in D85091 and D86559 it only handles the attribute when placed on
the case labels or the default labels.

It also marks the likelihood attribute as feature complete. There are more QoI
patches in the pipeline.

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

3 years ago[DSE] Add tests with noalias store between noop load/store.
Florian Hahn [Sat, 17 Oct 2020 15:50:31 +0000 (16:50 +0100)]
[DSE] Add tests with noalias store between noop load/store.

This adds 2 new tests from PR47887 and regenerates the check lines for
the file.

3 years ago[nfc] [lldb] Delete an empty trailing line.
Jan Kratochvil [Sun, 18 Oct 2020 08:16:00 +0000 (10:16 +0200)]
[nfc] [lldb] Delete an empty trailing line.

A patchset being prepared shows needless diffs.

3 years agoDelete unneeded X86RegisterInfo::hasReservedSpillSlot. NFC
Fangrui Song [Sun, 18 Oct 2020 04:34:43 +0000 (21:34 -0700)]
Delete unneeded X86RegisterInfo::hasReservedSpillSlot. NFC

Only PowerPC and RISCV need to override it.

3 years ago[X86] Remove unnecessary defaulted argument from function in X86FoldTablesEmitter...
Craig Topper [Sun, 18 Oct 2020 05:20:07 +0000 (22:20 -0700)]
[X86] Remove unnecessary defaulted argument from function in X86FoldTablesEmitter.cpp. NFC

Nothing ever calls it with anything other than the default value.
So just delete it and the code that handled the non-default value.

3 years ago[PrologEpilogInserter][test] Improve SpilledToReg test
Fangrui Song [Sun, 18 Oct 2020 03:36:21 +0000 (20:36 -0700)]
[PrologEpilogInserter][test] Improve SpilledToReg test

D39386 made CalleeSavedInfo possible to spill a register to another register
(vector register for POWER9) but did not actually test live-in.

3 years ago[X86] Mark the Key Locker instructions as NotMemoryFoldable to make the X86FoldTables...
Craig Topper [Sat, 17 Oct 2020 23:35:37 +0000 (16:35 -0700)]
[X86] Mark the Key Locker instructions as NotMemoryFoldable to make the X86FoldTablesEmitter not crash.

loadiwkey and aesenc128kl share the same opcode but one is memory
and one is register. But they're behavior is quite different. We
were crashing because one has an output register and one doesn't
and the backend couldn't account for that. But since they aren't
foldable we can just add NotMemoryFoldable so they won't be looked at.

3 years ago[Tests] Added tests for D88328
Dávid Bolvanský [Sun, 18 Oct 2020 00:06:39 +0000 (02:06 +0200)]
[Tests] Added tests for D88328

3 years ago[InferAttrs] Add argmemonly attribute to string libcalls
Dávid Bolvanský [Sat, 17 Oct 2020 20:23:39 +0000 (22:23 +0200)]
[InferAttrs] Add argmemonly attribute to string libcalls

Reviewed By: jdoerfert

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

3 years ago[BasicAA] Avoid alias query if result cannot be used (NFCI)
Nikita Popov [Sat, 17 Oct 2020 21:18:22 +0000 (23:18 +0200)]
[BasicAA] Avoid alias query if result cannot be used (NFCI)

Rather then querying first and then checking additional conditions,
check the conditions first. They are much cheaper than the alias
query.

3 years ago[BasicAA] Fix stale comment (NFC)
Nikita Popov [Sat, 17 Oct 2020 20:09:32 +0000 (22:09 +0200)]
[BasicAA] Fix stale comment (NFC)

DataLayout is always around...

3 years agoRevert "[InferAttrs] Add argmemonly attribute to string libcalls"
Dávid Bolvanský [Sat, 17 Oct 2020 21:29:02 +0000 (23:29 +0200)]
Revert "[InferAttrs] Add argmemonly attribute to string libcalls"

This reverts commit b77dd32a6fcc53908aaffc065d4d5b05026ddda7. Sanitizer tests are broken.

3 years ago[InferAttrs] Add argmemonly attribute to string libcalls
Dávid Bolvanský [Sat, 17 Oct 2020 20:23:39 +0000 (22:23 +0200)]
[InferAttrs] Add argmemonly attribute to string libcalls

Reviewed By: jdoerfert

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

3 years ago[SCEV] Model `ashr exact x, C` as `(abs(x) EXACT/u (1<<C)) * signum(x)`
Roman Lebedev [Sat, 17 Oct 2020 18:04:26 +0000 (21:04 +0300)]
[SCEV] Model `ashr exact x, C` as `(abs(x) EXACT/u (1<<C)) * signum(x)`

It's not pretty, but probably better than modelling it
as an opaque SCEVUnknown, i guess.

It is relevant e.g. for the loop that was brought up in
https://bugs.llvm.org/show_bug.cgi?id=46786#c26
as an example of what we'd be able to better analyze
once SCEV handles `ptrtoint` (D89456).

But as it is evident, even if we deal with `ptrtoint` there,
we also fail to model such an `ashr`.
Also, modeling of mul-of-exact-shr/div could use improvement.

As per alive2:
https://alive2.llvm.org/ce/z/tnfZKd
```
define i8 @src(i8 %0) {
  %2 = ashr exact i8 %0, 4
  ret i8 %2
}

declare i8 @llvm.abs(i8, i1)
declare i8 @llvm.smin(i8, i8)
declare i8 @llvm.smax(i8, i8)

define i8 @tgt(i8 %x) {
  %abs_x = call i8 @llvm.abs(i8 %x, i1 false)
  %div = udiv exact i8 %abs_x, 16
  %t0 = call i8 @llvm.smax(i8 %x, i8 -1)
  %t1 = call i8 @llvm.smin(i8 %t0, i8 1)
  %r = mul nsw i8 %div, %t1
  ret i8 %r
}
```
Transformation seems to be correct!

3 years ago[NFC][SCEV] Refactor getAbsExpr() out of createSCEV()
Roman Lebedev [Sat, 17 Oct 2020 17:53:11 +0000 (20:53 +0300)]
[NFC][SCEV] Refactor getAbsExpr() out of createSCEV()

3 years ago[NFC][SCEV] Add 'getMinusOne()' method
Roman Lebedev [Sat, 17 Oct 2020 13:24:49 +0000 (16:24 +0300)]
[NFC][SCEV] Add 'getMinusOne()' method

3 years ago[NFC][SCEV] Add some more ptrtoint/PR46786 -related tests
Roman Lebedev [Sat, 17 Oct 2020 12:43:32 +0000 (15:43 +0300)]
[NFC][SCEV] Add some more ptrtoint/PR46786 -related tests

3 years agoRevert "[clang-format] Fix AlignConsecutive on PP blocks"
Sylvestre Ledru [Sat, 17 Oct 2020 17:51:05 +0000 (19:51 +0200)]
Revert "[clang-format] Fix AlignConsecutive on PP blocks"

This reverts commit b2eb439317576ce718193763c12bff9fccdfc166.

Caused the regression:
https://bugs.llvm.org/show_bug.cgi?id=47589

Reviewed By: MyDeveloperDay

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

3 years ago[InstCombine] (~A & B) ^ A -> A | B
Sanjay Patel [Sat, 17 Oct 2020 16:19:04 +0000 (12:19 -0400)]
[InstCombine] (~A & B) ^ A -> A | B

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

3 years ago[NFC][ML] Avoid source of some signed/unsigned warnings in TFUtilsTest
Mircea Trofin [Sat, 17 Oct 2020 16:06:24 +0000 (09:06 -0700)]
[NFC][ML] Avoid source of some signed/unsigned warnings in TFUtilsTest

3 years ago[RISCV][ASAN] Fix passing XFAIL tests
Luís Marques [Sat, 17 Oct 2020 15:52:29 +0000 (16:52 +0100)]
[RISCV][ASAN] Fix passing XFAIL tests

These tests pass for RV64 Linux, but they are marked as XFAIL. This patch
fixes that.

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

3 years ago[MemCpyOpt] Extract common function for unwinding check
Nikita Popov [Sat, 17 Oct 2020 13:29:19 +0000 (15:29 +0200)]
[MemCpyOpt] Extract common function for unwinding check

These two cases should be using the same logic. Not NFC, as this
resolves the TODO regarding use of the underlying object.

3 years ago[NFC] fix some typos in LoopUnrollPass
Pedro Tammela [Sat, 17 Oct 2020 13:20:55 +0000 (14:20 +0100)]
[NFC] fix some typos in LoopUnrollPass

This patch fixes a couple of typos in the LoopUnrollPass.cpp comments

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

3 years ago[ARM] Basic getArithmeticReductionCost reduction costs
David Green [Sat, 17 Oct 2020 09:29:00 +0000 (10:29 +0100)]
[ARM] Basic getArithmeticReductionCost reduction costs

This adds some basic costs for MVE reductions - currently just costing
the simple legal add vectors as a single MVE instruction. More complex
costing can be added in the future when the framework more readily
allows it.

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

3 years ago[ARM] Add a very basic active_lane_mask cost
David Green [Sat, 17 Oct 2020 09:09:42 +0000 (10:09 +0100)]
[ARM] Add a very basic active_lane_mask cost

This adds a very basic cost for active_lane_mask under MVE - making the
assumption that they will be free and then apologizing for that in a
comment.

In reality they may either be free (by being nicely folded into a tail
predicated loop), cost the same as a VCTP or be expanded into vdup's,
adds and cmp's. It is difficult to detect the difference from a single
getIntrinsicInstrCost call, so makes the assumption that the vectorizer
is adding them, and only added them where it makes sense.

We may need to change this in the future to better model predicate costs
in the vectorizer, especially at -Os or non-tail predicated loops. The
vectorizer currently does not query the cost of these instructions but
that will change in the future and a zero cost there probably makes the
most sense at the moment.

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

3 years ago[lldb] Enable cmake policy CMP0077 for option()
Dave Lee [Sat, 17 Oct 2020 06:02:50 +0000 (23:02 -0700)]
[lldb] Enable cmake policy CMP0077 for option()

In lldb, explicitly set the "option() honors normal variables" CMake policy. This applies for
standalone lldb builds and matches what llvm, clang, etc do. This prevents potentially unwanted
clearing of variables like `LLVM_ENABLE_WARNINGS`, and also prevents unnecessary build warnings.

See: https://cmake.org/cmake/help/latest/policy/CMP0077.html

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

3 years agoRevert "Register TargetCXXABI.def as a textual header"
Dave Lee [Sat, 17 Oct 2020 07:13:48 +0000 (00:13 -0700)]
Revert "Register TargetCXXABI.def as a textual header"

Unbreak module builds.

TargetCXXABI.def has been removed in a revert: 79829a47040512fe54001db839ac59146ca55aec.

This reverts commit 0ff9116b36781d6fa61c25841edd53dc8f366bec.

3 years agoUn-indent the section on 'Writing Target Stop-Hooks in Python'
Jason Molenda [Sat, 17 Oct 2020 06:23:25 +0000 (23:23 -0700)]
Un-indent the section on 'Writing Target Stop-Hooks in Python'
it was ending up in a code block from the previous section,
instead of being its own section.

3 years agoAdd support for !noundef metatdata on loads
Juneyoung Lee [Sat, 17 Oct 2020 04:44:00 +0000 (13:44 +0900)]
Add support for !noundef metatdata on loads

This patch adds metadata !noundef and makes load instructions can optionally have it.
A load with !noundef always return a well-defined value (has no undef bit or isn't poison).
If the loaded value isn't well defined, the behavior is undefined.

This metadata can be used to encode the assumption from C/C++ that certain reads of variables should have well-defined values.
It is helpful for optimizing freeze instructions away, because freeze can be removed when its operand has well-defined value, and showing that a load from arbitrary location is well-defined is usually hard otherwise.

The same information can be encoded with llvm.assume with operand bundle; using metadata is chosen because I wasn't sure whether code motion can be freely done when llvm.assume is inserted from clang instead.
The existing codebase already is stripping unknown metadata when doing code motion, so using metadata is UB-safe as well.

Reviewed By: jdoerfert

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

3 years agoThis test includes a source that will produce basic blocks and hence sections with...
Sriraman Tallam [Sat, 17 Oct 2020 04:28:18 +0000 (21:28 -0700)]
This test includes a source that will produce basic blocks and hence sections with -fbasic-block-sections=all.

The test reorders the basic blocks to be dis-contiguous in the address space and checks if the back trace contains the right symbol.

Reviewed By: labath

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

3 years ago[LangRef] Rename the names of metadata in load/store's syntax (NFC)
Juneyoung Lee [Sat, 17 Oct 2020 04:29:58 +0000 (13:29 +0900)]
[LangRef] Rename the names of metadata in load/store's syntax (NFC)

Discussed in D89050

3 years ago[DebugInfo] Support for DWARF operator DW_OP_over
Alok Kumar Sharma [Sat, 17 Oct 2020 02:54:08 +0000 (08:24 +0530)]
[DebugInfo] Support for DWARF operator DW_OP_over

LLVM rejects DWARF operator DW_OP_over. This DWARF operator is needed
for Flang to support assumed rank array.

  Summary:
Currently LLVM rejects DWARF operator DW_OP_over. Below error is
produced when llvm finds this operator.
[..]
invalid expression
!DIExpression(151, 20, 16, 48, 30, 35, 80, 34, 6)
warning: ignoring invalid debug info in over.ll
[..]
There were some parts missing in support of this operator, which are
now completed.

  Testing
-added a unit testcase
-check-debuginfo
-check-llvm

Reviewed By: aprantl

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

3 years ago[TargetLowering] Extract simplifySetCCs ctpop into a separate function. NFCI
Craig Topper [Fri, 16 Oct 2020 22:42:49 +0000 (15:42 -0700)]
[TargetLowering] Extract simplifySetCCs ctpop into a separate function. NFCI

As requested in D89346. This allows us to add some early outs.

I reordered some checks a little bit to make the more common bail outs happen earlier. Like checking opcode before checking hasOneUse. And I moved the bit width check to make sure it was safe to look through a truncate to the spot where we look through truncates instead of after.

Reviewed By: spatel

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

3 years ago[MemorySSA] Verify clobbering within reachable blocks.
Alina Sbirlea [Sat, 17 Oct 2020 00:25:30 +0000 (17:25 -0700)]
[MemorySSA] Verify clobbering within reachable blocks.

Resolves PR45976.

3 years ago[NPM] Fix some PhaseOrdering tests under NPM
Arthur Eubanks [Fri, 16 Oct 2020 21:58:32 +0000 (14:58 -0700)]
[NPM] Fix some PhaseOrdering tests under NPM

These either already have corresponding NPM RUN lines,
or need to be fixed to not use -analyze.

3 years ago[AArch64][GlobalISel] Select csinc if a select has a 1 on RHS.
Amara Emerson [Thu, 15 Oct 2020 22:44:27 +0000 (15:44 -0700)]
[AArch64][GlobalISel] Select csinc if a select has a 1 on RHS.

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

3 years agoMake the check for whether we should memset(0) an aggregate
Richard Smith [Fri, 16 Oct 2020 23:46:49 +0000 (16:46 -0700)]
Make the check for whether we should memset(0) an aggregate
initialization a little smarter.

Look through casts that preserve zero-ness when determining if an
initializer is zero, so that we can handle cases like an {0} initializer
whose corresponding field is a type other than 'int'.

3 years ago[libomptarget] Fix copy-to motion for PTR_AND_OBJ entries where PTR is a struct member.
George Rokos [Fri, 16 Oct 2020 21:39:30 +0000 (14:39 -0700)]
[libomptarget] Fix copy-to motion for PTR_AND_OBJ entries where PTR is a struct member.

This patch fixes a problem whereby the pointee object of a PTR_AND_OBJ entry with a `map(to)` motion clause can be overwritten on the device even if its reference counter is >=1.

Currently, we check the reference counter of the parent struct in order to determine whether the motion clause should be respected, but since the pointee object is not part of the struct, it's got its own reference counter which should be used to enqueue the copy or discard it.

The same behavior has already been implemented in targetDataEnd (omptarget.cpp:539-540), but we somehow missed doing the same in targetDataBegin.

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

3 years agoFix accidental use of VLAs that causes these tests to fail after Clang
Richard Smith [Fri, 16 Oct 2020 22:13:23 +0000 (15:13 -0700)]
Fix accidental use of VLAs that causes these tests to fail after Clang
commit 552c6c2328723a248c2b4d2765f75d49129dff20.

3 years ago[PowerPC] Implementation of 128-bit Binary Vector Rotate builtins
Albion Fung [Fri, 16 Oct 2020 22:03:09 +0000 (18:03 -0400)]
[PowerPC] Implementation of 128-bit Binary Vector Rotate builtins

This patch implements 128-bit Binary Vector Rotate builtins for PowerPC10.

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

3 years agoFixed a failure when const matcher fails, added a test to catch
Rob Suderman [Fri, 16 Oct 2020 20:51:07 +0000 (13:51 -0700)]
Fixed a failure when const matcher fails, added a test to catch

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

3 years agoPR44406: Follow behavior of array bound constant folding in more recent versions...
Richard Smith [Fri, 16 Oct 2020 02:32:15 +0000 (19:32 -0700)]
PR44406: Follow behavior of array bound constant folding in more recent versions of GCC.

Old GCC used to aggressively fold VLAs to constant-bound arrays at block
scope in GNU mode. That's non-conforming, and more modern versions of
GCC only do this at file scope. Update Clang to do the same.

Also promote the warning for this from off-by-default to on-by-default
in all cases; more recent versions of GCC likewise warn on this by
default.

This is still slightly more permissive than GCC, as pointed out in
PR44406, as we still fold VLAs to constant arrays in structs, but that
seems justifiable given that we don't support VLA-in-struct (and don't
intend to ever support it), but GCC does.

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

3 years ago[objdump][macho] Check arch before formating reloc name as arm64 addend
Peng Guo [Fri, 16 Oct 2020 20:47:46 +0000 (13:47 -0700)]
[objdump][macho] Check arch before formating reloc name as arm64 addend

Before formating ARM64_RELOC_ADDEND relocation target name as a hex
number, the architecture need to be checked since other architectures
can define a different relocation type with the same integer as
ARM64_RELOC_ADDEND.

Reviewed By: MaskRay

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

3 years ago[lldb] Implement ObjCExceptionThrowFrameRecognizer::GetName()
Dave Lee [Fri, 16 Oct 2020 18:46:35 +0000 (11:46 -0700)]
[lldb] Implement ObjCExceptionThrowFrameRecognizer::GetName()

Implement `GetName` for `ObjCExceptionThrowFrameRecognizer`. Otherwise, `frame recognizer list` shows "(internal)" for the name.

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

3 years agoRevert "make the AsmPrinterHandler array public"
Jameson Nash [Fri, 16 Oct 2020 21:22:07 +0000 (17:22 -0400)]
Revert "make the AsmPrinterHandler array public"

I messed up one of the tests.

3 years ago[Format/ObjC] Correctly handle base class with lightweight generics and protocol
Ben Hamilton [Thu, 15 Oct 2020 21:00:00 +0000 (15:00 -0600)]
[Format/ObjC] Correctly handle base class with lightweight generics and protocol

ClangFormat does not correctly handle an Objective-C interface declaration
with both lightweight generics and a protocol conformance.

This simple example:

```
@interface Foo : Bar <Baz> <Blech>

@end
```

means `Foo` extends `Bar` (a lightweight generic class whose type
parameter is `Baz`) and also conforms to the protocol `Blech`.

ClangFormat should not apply any changes to the above example, but
instead it currently formats it quite poorly:

```
@interface Foo : Bar <Baz>
<Blech>

    @end
    ```

The bug is that `UnwrappedLineParser` assumes an open-angle bracket
after a base class name is a protocol list, but it can also be a
lightweight generic specification.

This diff fixes the bug by factoring out the logic to parse
lightweight generics so it can apply both to the declared class
as well as the base class.

Test Plan: New tests added. Ran tests with:
  % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests
  Confirmed tests failed before diff and passed after diff.

Reviewed By: sammccall, MyDeveloperDay

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

3 years agoRevert "Fix Windows llvm-objdump tests"
Renato Golin [Fri, 16 Oct 2020 20:49:47 +0000 (21:49 +0100)]
Revert "Fix Windows llvm-objdump tests"

It had already been fixed in a different way.

3 years ago[AMDGPU] Fix gfx1032 description in AMDGPUUsage.rst. NFC.
Stanislav Mekhanoshin [Fri, 16 Oct 2020 17:18:47 +0000 (10:18 -0700)]
[AMDGPU] Fix gfx1032 description in AMDGPUUsage.rst. NFC.

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

3 years agoFix Windows llvm-objdump tests
Renato Golin [Fri, 16 Oct 2020 20:26:46 +0000 (21:26 +0100)]
Fix Windows llvm-objdump tests

Broken in e95f9a23fad with path issues.

3 years agomake the AsmPrinterHandler array public
Jameson Nash [Thu, 15 Oct 2020 21:19:10 +0000 (17:19 -0400)]
make the AsmPrinterHandler array public

This lets external consumers customize the output, similar to how
AssemblyAnnotationWriter lets the caller define callbacks when printing
IR. The array of handlers already existed, this just cleans up the code
so that it can be exposed publically.

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

3 years agoTreat constant contexts as being in the default rounding mode.
Richard Smith [Wed, 14 Oct 2020 02:14:13 +0000 (19:14 -0700)]
Treat constant contexts as being in the default rounding mode.

This addresses a regression where pretty much all C++ compilations using
-frounding-math now fail, due to rounding being performed in constexpr
function definitions in the standard library.

This follows the "manifestly constant evaluated" approach described in
https://reviews.llvm.org/D87528#2270676 -- evaluations that are required
to succeed at compile time are permitted even in regions with dynamic
rounding modes, as are (unfortunately) the evaluation of the
initializers of local variables of const integral types.

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

3 years agoExtend memset-to-zero optimization to C++11 aggregate functional casts
Richard Smith [Fri, 16 Oct 2020 20:18:52 +0000 (13:18 -0700)]
Extend memset-to-zero optimization to C++11 aggregate functional casts
Aggr{...}.

We previously missed these cases due to not stepping over the additional
AST nodes representing their syntactic form.

3 years ago[VectorCombine] Avoid crossing address space boundaries.
Artem Belevich [Fri, 16 Oct 2020 18:19:27 +0000 (11:19 -0700)]
[VectorCombine] Avoid crossing address space boundaries.

We can not bitcast pointers across different address spaces, and VectorCombine
should be careful when it attempts to find the original source of the loaded
data.

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

3 years ago[AMDGPU] Drop array size in AMDGCNGPUs and R600GPUs
Stanislav Mekhanoshin [Fri, 16 Oct 2020 17:44:03 +0000 (10:44 -0700)]
[AMDGPU] Drop array size in AMDGCNGPUs and R600GPUs

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

3 years agoRevert "Recommit "[SCEV] Use nw flag and symbolic iteration count to sharpen ranges...
Nikita Popov [Fri, 16 Oct 2020 19:13:41 +0000 (21:13 +0200)]
Revert "Recommit "[SCEV] Use nw flag and symbolic iteration count to sharpen ranges of AddRecs""

This reverts commit 32b72c3165bf65cca2e8e6197b59eb4c4b60392a.

While better than before, this change still introduces a large
compile-time regression (>3% on mafft):
https://llvm-compile-time-tracker.com/compare.php?from=fbd62fe60fb2281ca33da35dc25ca3c87ec0bb51&to=32b72c3165bf65cca2e8e6197b59eb4c4b60392a&stat=instructions

Additionally, the logic here doesn't look quite right to me,
I will comment in more detail on the differential revision.

3 years ago[SCEV] Add additional tests where the max BTC is limited by wrapping.
Florian Hahn [Fri, 16 Oct 2020 19:16:32 +0000 (20:16 +0100)]
[SCEV] Add additional tests where the max BTC is limited by wrapping.

3 years ago[CGSCC] Add -abort-on-max-devirt-iterations-reached option
Arthur Eubanks [Fri, 16 Oct 2020 00:46:10 +0000 (17:46 -0700)]
[CGSCC] Add -abort-on-max-devirt-iterations-reached option

Aborts if we hit the max devirtualization iteration.
Will be useful for testing that changes to devirtualization don't cause
devirtualization to repeat passes more times than necessary.

Reviewed By: rnk

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

3 years ago[flang] Disallow pointer constants
Peter Steinfeld [Fri, 16 Oct 2020 18:48:55 +0000 (11:48 -0700)]
[flang] Disallow pointer constants

None of the other Fortran compilers allow them.

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

3 years ago[AMDGPU] Run hazard recognizer pass later
Austin Kerbow [Thu, 8 Oct 2020 22:53:25 +0000 (15:53 -0700)]
[AMDGPU] Run hazard recognizer pass later

If instructions were removed in peephole passes after the hazard recognizer was
run it is possible that new hazards could be introduced.

Fixes: SWDEV-253090

Reviewed By: rampitec, arsenm

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

3 years ago[mlir] Update SCCP and the Inliner to use SymbolTableCollection for symbol lookups
River Riddle [Fri, 16 Oct 2020 18:57:10 +0000 (11:57 -0700)]
[mlir] Update SCCP and the Inliner to use SymbolTableCollection for symbol lookups

This transforms the symbol lookups to O(1) from O(NM), greatly speeding up both passes. For a large MLIR module this shaved seconds off of the compilation time.

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

3 years ago[mlir] Add a new SymbolUserOpInterface class
River Riddle [Fri, 16 Oct 2020 18:57:00 +0000 (11:57 -0700)]
[mlir] Add a new SymbolUserOpInterface class

The initial goal of this interface is to fix the current problems with verifying symbol user operations, but can extend beyond that in the future. The current problems with the verification of symbol uses are:
* Extremely inefficient:
Most current symbol users perform the symbol lookup using the slow O(N) string compare methods, which can lead to extremely long verification times in large modules.
* Invalid/break the constraints of verification pass
If the symbol reference is not-flat(and even if it is flat in some cases) a verifier for an operation is not permitted to touch the referenced operation because it may be in the process of being mutated by a different thread within the pass manager.

The new SymbolUserOpInterface exposes a method `verifySymbolUses` that will be invoked from the parent symbol table to allow for verifying the constraints of any referenced symbols. This method is passed a `SymbolTableCollection` to allow for O(1) lookups of any necessary symbol operation.

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

3 years ago[mlir] Optimize symbol related checks in SymbolDCE
River Riddle [Fri, 16 Oct 2020 18:56:52 +0000 (11:56 -0700)]
[mlir] Optimize symbol related checks in SymbolDCE

This revision contains two optimizations related to symbol checking:
* Optimize SymbolOpInterface to only check for a name attribute if the operation is an optional symbol.
This removes an otherwise unnecessary attribute lookup from a majority of symbols.
* Add a new SymbolTableCollection class to represent a collection of SymbolTables.
This allows for perfoming non-flat symbol lookups in O(1) time by caching SymbolTables for symbol table operations. This class is very useful for algorithms that operate on multiple symbol tables, either recursively or not.

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

3 years ago[mlir] Add a utility class, ThreadLocalCache, for storing non static thread local...
River Riddle [Fri, 16 Oct 2020 18:56:43 +0000 (11:56 -0700)]
[mlir] Add a utility class, ThreadLocalCache, for storing non static thread local objects.

(Note: This is a reland of D82597)

This class allows for defining thread local objects that have a set non-static lifetime. This internals of the cache use a static thread_local map between the various different non-static objects and the desired value type. When a non-static object destructs, it simply nulls out the entry in the static map. This will leave an entry in the map, but erase any of the data for the associated value. The current use cases for this are in the MLIRContext, meaning that the number of items in the static map is ~1-2 which aren't particularly costly enough to warrant the complexity of pruning. If a use case arises that requires pruning of the map, the functionality can be added.

This is especially useful in the context of MLIR for implementing thread-local caching of context level objects that would otherwise have very high lock contention. This revision adds a thread local cache in the MLIRContext for attributes, identifiers, and types to reduce some of the locking burden. This led to a speedup of several seconds when compiling a somewhat large mlir module.

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

3 years ago[docs] Fix some out-of-date / inaccurate text and missing formatting in the User...
Richard Smith [Fri, 16 Oct 2020 18:59:24 +0000 (11:59 -0700)]
[docs] Fix some out-of-date / inaccurate text and missing formatting in the User's Manual.

3 years ago[llvm-objdump][test] Unsupport system-windows for source-interleave-prefix.test
Fangrui Song [Fri, 16 Oct 2020 18:44:27 +0000 (11:44 -0700)]
[llvm-objdump][test] Unsupport system-windows for source-interleave-prefix.test

3 years agoAdd support for more OS types to AddClangModuleCompilationOptionsForSDKType()
Adrian Prantl [Fri, 16 Oct 2020 18:42:08 +0000 (11:42 -0700)]
Add support for more OS types to AddClangModuleCompilationOptionsForSDKType()

This patch also avoids hardcoding the clang options, which makes it
less likely for them to become out-of-date.

rdar://problem/63791367+66927829

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

3 years ago[llvm-objdump][test] Delete source-interleave-prefix-windows.test
Fangrui Song [Fri, 16 Oct 2020 18:42:12 +0000 (11:42 -0700)]
[llvm-objdump][test] Delete source-interleave-prefix-windows.test

It needs more work: http://45.33.8.238/win/25999/step_11.txt

3 years ago[AArch64][GlobalISel] Add selection support for v2s32 and v2s64 reductions for FADD...
Amara Emerson [Fri, 9 Oct 2020 19:38:39 +0000 (12:38 -0700)]
[AArch64][GlobalISel] Add selection support for v2s32 and v2s64 reductions for FADD/ADD.

We'll need legalizer lower() support for the other types to work.

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

3 years ago[test] Pin null-function.ll to legacy PM
Arthur Eubanks [Fri, 16 Oct 2020 18:23:26 +0000 (11:23 -0700)]
[test] Pin null-function.ll to legacy PM

The NPM prints CGSCCs in a different way.

3 years ago[gn build] Port 3d4bba302d2
LLVM GN Syncbot [Fri, 16 Oct 2020 18:13:18 +0000 (18:13 +0000)]
[gn build] Port 3d4bba302d2

3 years ago[gn build] (manually) port 3d4bba302d246
Nico Weber [Fri, 16 Oct 2020 18:12:38 +0000 (14:12 -0400)]
[gn build] (manually) port 3d4bba302d246

3 years ago[libcxx] [test] Fix string type handling in a few fairly trivial class.path tests
Martin Storsjö [Thu, 15 Oct 2020 08:55:10 +0000 (11:55 +0300)]
[libcxx] [test] Fix string type handling in a few fairly trivial class.path tests

Use string() for convenience for testing where possible, but keep using
native() for move tests where we want to check that no allocations are
made, constructing a reference fs::path::string_type instead.

Use the right value_type in a few places.

Make the synop test check for the right types and for the expected
preferred separator.

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

3 years ago[Indvars][NFCI] Simplify assertion.
Benjamin Kramer [Fri, 16 Oct 2020 17:58:05 +0000 (19:58 +0200)]
[Indvars][NFCI] Simplify assertion.

This should be semantically identical. Also avoids unused variable
warnings in Release builds.