platform/upstream/llvm.git
3 years agoReapply [ADT] function_ref's constructor is unavailable if the argument is not callable.
Sam McCall [Wed, 7 Oct 2020 14:37:53 +0000 (16:37 +0200)]
Reapply [ADT] function_ref's constructor is unavailable if the argument is not callable.

This reverts commit 281703e67ffaee8e26efef86e0df3e145477f4cb.

GCC 5.4 bugs are worked around by avoiding use of variable templates.

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

3 years ago[clang-format][tests] Fix MacroExpander lexer not parsing C++ keywords
Alex Richardson [Wed, 7 Oct 2020 15:29:22 +0000 (16:29 +0100)]
[clang-format][tests] Fix MacroExpander lexer not parsing C++ keywords

While debugging a different clang-format failure, I tried to reuse the
MacroExpander lexer, but was surprised to see that it marks all C++
keywords (e.g. const, decltype) as being of type identifier. After stepping
through the ::format() code, I noticed that the difference between these
two is that the identifier table was not being initialized based on the
FormatStyle, so only basic tokens such as tok::semi, tok::plus, etc. were
being handled.

Reviewed By: klimek

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

3 years ago[clang-format][NFC] Store FormatToken::Type as an enum instead of bitfield
Alex Richardson [Wed, 7 Oct 2020 15:29:10 +0000 (16:29 +0100)]
[clang-format][NFC] Store FormatToken::Type as an enum instead of bitfield

This improves the debugging experience since LLDB will print the enumerator
name instead of a decimal number. This changes TokenType to have uint8_t
as the underlying type and moves it after the remaining bitfields to avoid
increasing the size of FormatToken.

Reviewed By: MyDeveloperDay

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

3 years ago[MemCpyOpt] Add additional callslot test cases (NFC)
Nikita Popov [Tue, 6 Oct 2020 20:10:10 +0000 (22:10 +0200)]
[MemCpyOpt] Add additional callslot test cases (NFC)

For cases where the destination is captured.

3 years ago[NFC][InstCombine] Autogenerate a few tests being affected by upcoming patch
Roman Lebedev [Wed, 7 Oct 2020 15:59:40 +0000 (18:59 +0300)]
[NFC][InstCombine] Autogenerate a few tests being affected by upcoming patch

3 years ago[Tests] Precommit test showing gap around load forwarding of vectors in instcombine
Philip Reames [Wed, 7 Oct 2020 15:56:13 +0000 (08:56 -0700)]
[Tests] Precommit test showing gap around load forwarding of vectors in instcombine

3 years ago[gn build] Port ddf1864ace4
LLVM GN Syncbot [Wed, 7 Oct 2020 15:50:43 +0000 (15:50 +0000)]
[gn build] Port ddf1864ace4

3 years agoBPF: add AdjustOpt IR pass to generate verifier friendly codes
Yonghong Song [Thu, 6 Aug 2020 16:06:43 +0000 (09:06 -0700)]
BPF: add AdjustOpt IR pass to generate verifier friendly codes

Add an IR phase right before main module optimization.
This is to modify IR to restrict certain downward optimizations
in order to generate verifier friendly code.
  > prevent certain instcombine optimizations, handling both
    in-block/cross-block instcombines.
  > avoid speculative code motion if the variable used in
    condition is also used in the later blocks.

Internally, a bpf IR builtin
  result = __builtin_bpf_passthrough(seq_num, result)
is used to enforce ordering. This builtin is only used
during target independent IR optimizations and it will
be removed at the beginning of target dependent IR
optimizations.

For example, removing the following workaround,
  --- a/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
  +++ b/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
  @@ -47,7 +47,7 @@ int sysctl_tcp_mem(struct bpf_sysctl *ctx)
          /* a workaround to prevent compiler from generating
           * codes verifier cannot handle yet.
           */
  -       volatile int ret;
  +       int ret;
this patch is able to generate code which passed the verifier.

To disable optimization, users need to use "opt" command like below:
  clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes test.c
  // disable icmp serialization
  opt -O2 -bpf-disable-serialize-icmp test.ll | llvm-dis > t.ll
  // disable avoid-speculation
  opt -O2 -bpf-disable-avoid-speculation test.ll | llvm-dis > t.ll
  llc t.ll

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

3 years ago[SystemZ][z/OS] Add test of zero length bitfield type size larger than target zero...
Fanbo Meng [Wed, 7 Oct 2020 15:33:19 +0000 (11:33 -0400)]
[SystemZ][z/OS] Add test of zero length bitfield type size larger than target zero length bitfield boundary

Reviewed By: hubert.reinterpretcast

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

3 years agoIntroduce subtraction for FlatAffineConstraints
Arjun P [Wed, 7 Oct 2020 15:16:11 +0000 (17:16 +0200)]
Introduce subtraction for FlatAffineConstraints

Subtraction is a foundational arithmetic operation that is often used when computing, for example, data transfer sets or cache hits. Since the result of subtraction need not be a convex polytope, a new class `PresburgerSet` is introduced to represent unions of convex polytopes.

Reviewed By: ftynse, bondhugula

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

3 years ago[clangd] Fix argument type (bool->float).
Adam Czachorowski [Wed, 7 Oct 2020 15:02:16 +0000 (17:02 +0200)]
[clangd] Fix argument type (bool->float).

The default value is 1.3f, but it was cast to true, which is not a good
base for code completion score.

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

3 years ago[AMDGPU] Support disassembly for AMDGPU kernel descriptors
Ronak Chauhan [Wed, 7 Oct 2020 02:44:46 +0000 (08:14 +0530)]
[AMDGPU] Support disassembly for AMDGPU kernel descriptors

Decode AMDGPU Kernel descriptors as assembler directives.

Reviewed By: scott.linder, jhenderson, kzhuravl

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

3 years ago[SVE] Lower fixed length VECREDUCE_OR operation
Cameron McInally [Wed, 7 Oct 2020 14:26:53 +0000 (09:26 -0500)]
[SVE] Lower fixed length VECREDUCE_OR operation

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

3 years ago[AMDGPU] Use @LINE for error checking in gfx10.3 assembler tests
Jay Foad [Wed, 7 Oct 2020 14:48:01 +0000 (15:48 +0100)]
[AMDGPU] Use @LINE for error checking in gfx10.3 assembler tests

3 years agoRevert "[ADT] function_ref's constructor is unavailable if the argument is not callable."
Sam McCall [Wed, 7 Oct 2020 14:36:38 +0000 (16:36 +0200)]
Revert "[ADT] function_ref's constructor is unavailable if the argument is not callable."

This reverts commit 4cae6228d129d4c4dfb156c043977bb6b5690031.

Breaks GCC build:
http://lab.llvm.org:8011/#/builders/8/builds/33/steps/6/logs/stdio

3 years ago[gn build] (manually) port ce1365f8f7e
Nico Weber [Wed, 7 Oct 2020 14:33:40 +0000 (10:33 -0400)]
[gn build] (manually) port ce1365f8f7e

3 years ago[ADT] function_ref's constructor is unavailable if the argument is not callable.
Sam McCall [Tue, 6 Oct 2020 14:35:35 +0000 (16:35 +0200)]
[ADT] function_ref's constructor is unavailable if the argument is not callable.

This allows overload sets containing function_ref arguments to work correctly
Otherwise they're ambiguous as anything "could be" converted to a function_ref.

This matches proposed std::function_ref, absl::function_ref, etc.

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

3 years ago[mlir] fix the types used during the generation of the kernel param array
Tobias Gysi [Wed, 7 Oct 2020 14:18:46 +0000 (16:18 +0200)]
[mlir] fix the types used during the generation of the kernel param array

The patch fixes the types used to access the elements of the kernel parameter structure from a pointer to the structure to a pointer to the actual parameter type.

Reviewed By: csigg

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

3 years ago[obj2yaml] - Rename `Group` to `GroupSection`. NFC.
Georgii Rymar [Tue, 6 Oct 2020 13:04:15 +0000 (16:04 +0300)]
[obj2yaml] - Rename `Group` to `GroupSection`. NFC.

The `Group` class represents a group section and it is
named inconsistently with other sections which all has
the "Section" suffix. It is sometimes confusing,
this patch addresses the issue.

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

3 years ago[llvm-readelf] - Implement --addrsig option.
Georgii Rymar [Mon, 5 Oct 2020 13:51:58 +0000 (16:51 +0300)]
[llvm-readelf] - Implement --addrsig option.

We have `--addrsig` implemented for `llvm-readobj`.
Usually it is convenient to use a single tool for dumping,
so it seems we might want to implement `--addrsig` for `llvm-readelf` too.

I've selected a simple output format which is a bit similar to one,
used for dumping of the symbol table. It looks like:

```
Address-significant symbols section '.llvm_addrsig' contains 2 entries:
   Num: Name
     1: foo
     2: bar
```

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

3 years ago[AMDGPU][MC] Improved diagnostics for instructions with missing features
Dmitry Preobrazhensky [Wed, 7 Oct 2020 13:11:37 +0000 (16:11 +0300)]
[AMDGPU][MC] Improved diagnostics for instructions with missing features

Reviewers: rampitec

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

3 years ago[libc++] Use the existing CMake caches when running build bots
Louis Dionne [Wed, 7 Oct 2020 13:27:19 +0000 (09:27 -0400)]
[libc++] Use the existing CMake caches when running build bots

3 years ago[lldb] Check for and use ptsname_r if available
Pavel Labath [Fri, 2 Oct 2020 11:38:09 +0000 (13:38 +0200)]
[lldb] Check for and use ptsname_r if available

ptsname is not thread-safe. ptsname_r is available on most (but not all)
systems -- use it preferentially.

In the patch I also improve the thread-safety of the ptsname fallback
path by wrapping it in a mutex. This should guarantee the safety of a
typical ptsname implementation using a single static buffer, as long as
all callers go through this function.

I also remove the error arguments, as the only way this function can
fail is if the "primary" fd is not valid. This is a programmer error as
this requirement is documented, and all callers ensure that is the case.

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

3 years ago[lldb/docs] Clarify python/swig version incompatibility
Pavel Labath [Tue, 6 Oct 2020 15:39:08 +0000 (17:39 +0200)]
[lldb/docs] Clarify python/swig version incompatibility

The problematic combo is a debug python>=3.7 && swig<4.0.

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

3 years ago[libc++] Add a CMake option to control whether the debug mode is supported
Louis Dionne [Tue, 6 Oct 2020 20:46:58 +0000 (16:46 -0400)]
[libc++] Add a CMake option to control whether the debug mode is supported

Some libc++ builds may want to disable support for the debug mode,
for example to reduce code size or because the current implementation
of the debug mode requires a global map. This commit adds the
LIBCXX_ENABLE_DEBUG_MODE CMake option and ties it into the test
suite.

It also adds a CI job to test this configuration going forward.

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

3 years ago[libc++] Make sure __clear_and_shrink() maintains string invariants
Louis Dionne [Mon, 5 Oct 2020 20:16:13 +0000 (16:16 -0400)]
[libc++] Make sure __clear_and_shrink() maintains string invariants

__clear_and_shrink() was added in D41976, and a test was added alongside
it to make sure that the string invariants were maintained. However, it
appears that the test never ran under UBSan before, which would have
highlighted the fact that it doesn't actually maintain the string
invariants.

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

3 years ago[mlir] Add support for diagnostics in C API.
Alex Zinenko [Wed, 7 Oct 2020 12:38:10 +0000 (14:38 +0200)]
[mlir] Add support for diagnostics in C API.

Add basic support for registering diagnostic handlers with the context
(actually, the diagnostic engine contained in the context) and processing
diagnostic messages from the C API.

Reviewed By: stellaraccident

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

3 years ago[LLD] [MinGW] Move an option definitions to alphabetical order, wrap a line. NFC.
Martin Storsjö [Tue, 6 Oct 2020 10:03:49 +0000 (13:03 +0300)]
[LLD] [MinGW] Move an option definitions to alphabetical order, wrap a line. NFC.

3 years agoInstCombine: Negator: don't rely on complexity sorting already being performed (PR47752)
Roman Lebedev [Wed, 7 Oct 2020 10:52:25 +0000 (13:52 +0300)]
InstCombine: Negator: don't rely on complexity sorting already being performed (PR47752)

In some cases, we can negate instruction if only one of it's operands
negates. Previously, we assumed that constants would have been
canonicalized to RHS already, but that isn't guaranteed to happen,
because of InstCombine worklist visitation order,
as the added test (previously-hanging) shows.

So if we only need to negate a single operand,
we should ensure ourselves that we try constant operand first.
Do that by re-doing the complexity sorting ourselves,
when we actually care about it.

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

3 years ago[AMDGPU] Implement hardware bug workaround for image instructions
Rodrigo Dominguez [Fri, 3 Apr 2020 21:37:51 +0000 (17:37 -0400)]
[AMDGPU] Implement hardware bug workaround for image instructions

Summary:
This implements a workaround for a hardware bug in gfx8 and gfx9,
where register usage is not estimated correctly for image_store and
image_gather4 instructions when D16 is used.

Change-Id: I4e30744da6796acac53a9b5ad37ac1c2035c8899

Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, kerbowa, llvm-commits

Tags: #llvm

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

3 years ago[InstCombine] Tweak funnel by constant tests for better shl/lshr commutation coverage
Simon Pilgrim [Wed, 7 Oct 2020 10:46:46 +0000 (11:46 +0100)]
[InstCombine] Tweak funnel by constant tests for better shl/lshr commutation coverage

3 years ago[ARM] Regenerate vldlane tests
Simon Pilgrim [Wed, 7 Oct 2020 10:45:52 +0000 (11:45 +0100)]
[ARM] Regenerate vldlane tests

To help make the diffs in D88569 clearer

3 years ago[LAA] Add test for PR47751, which currently uses wrong bounds.
Florian Hahn [Wed, 7 Oct 2020 10:14:55 +0000 (11:14 +0100)]
[LAA] Add test for PR47751, which currently uses wrong bounds.

3 years ago[SDag] SimplifyDemandedBits: simplify to FP constant if all bits known
Jay Foad [Wed, 30 Sep 2020 17:50:34 +0000 (18:50 +0100)]
[SDag] SimplifyDemandedBits: simplify to FP constant if all bits known

We were already doing this for integer constants. This patch implements
the same thing for floating point constants.

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

3 years ago[Test] Add one more test where we can avoid creating trunc
Max Kazantsev [Wed, 7 Oct 2020 08:04:40 +0000 (15:04 +0700)]
[Test] Add one more test where we can avoid creating trunc

3 years ago[mlir][NFC] Style cleanup in comments
Tres Popp [Wed, 7 Oct 2020 08:04:45 +0000 (10:04 +0200)]
[mlir][NFC] Style cleanup in comments

3 years ago[clangd] Don't set the Underlying bit on targets of UsingDecls.
Haojian Wu [Wed, 7 Oct 2020 08:01:04 +0000 (10:01 +0200)]
[clangd] Don't set the Underlying bit on targets of UsingDecls.

With this patch, we don't treat `using ns::X` as a first-class declaration like `using Z = ns::Y`, reference to X that goes through this using-decl is considered a direct reference (without the Underlying bit).

Fix the workaround in https://reviews.llvm.org/D87225 and https://reviews.llvm.org/D74054.

Reviewed By: sammccall

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

3 years ago[clang] Use isCompoundAssignmentOp to simplify the code, NFC.
Haojian Wu [Wed, 7 Oct 2020 07:50:43 +0000 (09:50 +0200)]
[clang] Use isCompoundAssignmentOp to simplify the code, NFC.

3 years ago[AST][RecoveryExpr] Support dependent conditional operators in C for error recovery.
Haojian Wu [Wed, 7 Oct 2020 07:33:57 +0000 (09:33 +0200)]
[AST][RecoveryExpr] Support dependent conditional operators in C for error recovery.

suppress spurious "typecheck_cond_expect_scalar" diagnostic.

Reviewed By: sammccall

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

3 years ago[Support][unittests] Enforce alignment in ConvertUTFTest
Rainer Orth [Wed, 7 Oct 2020 07:08:41 +0000 (09:08 +0200)]
[Support][unittests] Enforce alignment in ConvertUTFTest

`LLVM-Unit :: Support/./SupportTests/ConvertUTFTest.ConvertUTF16LittleEndianToUTF8String`
`FAIL`s on Solaris/sparcv9:

In `llvm/lib/Support/ConvertUTFWrapper.cpp` (`convertUTF16ToUTF8String`)
the `SrcBytes` arg is reinterpreted/accessed as `UTF16` (`unsigned short`,
which requires 2-byte alignment on strict-alignment targets like Sparc)
without anything guaranteeing the alignment, so the access yields a
`SIGBUS`.

This patch avoids this by enforcing the required alignment in the callers.

Tested on `sparcv9-sun-solaris2.11`.

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

3 years ago[NFC] Use getZero instead of getConstant(0)
Max Kazantsev [Wed, 7 Oct 2020 06:52:48 +0000 (13:52 +0700)]
[NFC] Use getZero instead of getConstant(0)

3 years ago[lldb] Format unix signal table (NFC)
Jonas Devlieghere [Wed, 7 Oct 2020 06:33:04 +0000 (23:33 -0700)]
[lldb] Format unix signal table (NFC)

Restore unix signal table to its original glory and mark it as not to be
clang-formatted.

3 years ago[SROA] rewritePartition()/findCommonType(): if uses have conflicting type, try getTyp...
Roman Lebedev [Wed, 7 Oct 2020 06:17:23 +0000 (09:17 +0300)]
[SROA] rewritePartition()/findCommonType(): if uses have conflicting type, try getTypePartition() before falling back to largest integral use type (PR47592)

And another step towards transformss not introducing inttoptr and/or
ptrtoint casts that weren't there already.

In this case, when load/store uses have conflicting types,
instead of falling back to the iN, we can try to use allocated sub-type.
As disscussed, this isn't the best idea overall (we shouldn't rely on
allocated type), but it works fine as a temporary measure.

I've measured, and @ `-O3` as of vanilla llvm test-suite + RawSpeed,
this results in +0.05% more bitcasts, -5.51% less inttoptr
and -1.05% less ptrtoint (at the end of middle-end opt pipeline)

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

Reviewed By: efriedma

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

3 years agoBPF: avoid duplicated globals for CORE relocations
Yonghong Song [Wed, 7 Oct 2020 03:29:09 +0000 (20:29 -0700)]
BPF: avoid duplicated globals for CORE relocations

This patch fixed two issues related with relocation globals.
In LLVM, if a global, e.g. with name "g", is created and
conflict with another global with the same name, LLVM will
rename the global, e.g., with a new name "g.2". Since
relocation global name has special meaning, we do not want
llvm to change it, so internally we have logic to check
whether duplication happens or not. If happens, just reuse
the previous global.

The first bug is related to non-btf-id relocation
(BPFAbstractMemberAccess.cpp). Commit 54d9f743c8b0
("BPF: move AbstractMemberAccess and PreserveDIType passes
to EP_EarlyAsPossible") changed ModulePass to FunctionPass,
i.e., handling each function at a time. But still just
one BPFAbstractMemberAccess object is created so module
level de-duplication still possible. Commit 40251fee0084
("[BPF][NewPM] Make BPFTargetMachine properly adjust NPM optimizer
pipeline") made a change to create a BPFAbstractMemberAccess
object per function so module level de-duplication is not
possible any more without going through all module globals.
This patch simply changed the map which holds reloc globals
as class static, so it will be available to all
BPFAbstractMemberAccess objects for different functions.

The second bug is related to btf-id relocation
(BPFPreserveDIType.cpp). Before Commit 54d9f743c8b0, the pass
is a ModulePass, so we have a local variable, incremented for
each instance, and works fine. But after Commit 54d9f743c8b0,
the pass becomes a FunctionPass. Local variable won't work
properly since different functions will start with the same
initial value. Fix the issue by change the local count variable
as static, so it will be truely unique across the whole module
compilation.

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

3 years ago[Test] Add test showing that we can avoid inserting trunc/zext
Max Kazantsev [Wed, 7 Oct 2020 05:18:24 +0000 (12:18 +0700)]
[Test] Add test showing that we can avoid inserting trunc/zext

3 years agoReapply "[OpenMP][FIX] Verify compatible types for declare variant calls" D88384
Johannes Doerfert [Tue, 29 Sep 2020 13:08:02 +0000 (08:08 -0500)]
Reapply "[OpenMP][FIX] Verify compatible types for declare variant calls" D88384

This reapplies D88384 with the minor modification that an assertion was
changed to a regular conditional and graceful exit from
ASTContext::mergeTypes.

3 years ago[MachineInstr] exclude call instruction in mayAlias
Chen Zheng [Wed, 7 Oct 2020 04:12:21 +0000 (00:12 -0400)]
[MachineInstr] exclude call instruction in mayAlias

we now get noAlias result for a call instruction and other
load/store/call instructions if we query mayAlias.
This is not right as call instruction is not with mayloadorstore,
but it may alter the memory.

This patch fixes this wrong alias query.

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

3 years ago[PowerPC] implement target hook getTgtMemIntrinsic
Chen Zheng [Sun, 27 Sep 2020 08:13:16 +0000 (04:13 -0400)]
[PowerPC] implement target hook getTgtMemIntrinsic

This patch can make pass recognize Powerpc related memory intrinsics.

Reviewed By: steven.zhang

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

3 years ago[PowerPC] add more builtins for PPCTargetLowering::getTgtMemIntrinsic
Chen Zheng [Sun, 27 Sep 2020 08:47:46 +0000 (04:47 -0400)]
[PowerPC] add more builtins for PPCTargetLowering::getTgtMemIntrinsic

Reviewed By: steven.zhang

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

3 years ago[CodeGen][TailDuplicator] Don't duplicate blocks with INLINEASM_BR
Bill Wendling [Wed, 7 Oct 2020 00:54:36 +0000 (17:54 -0700)]
[CodeGen][TailDuplicator] Don't duplicate blocks with INLINEASM_BR

Tail duplication of a block with an INLINEASM_BR may result in a PHI
node on the indirect branch. This is okay, but it also introduces a copy
for that PHI node *after* the INLINEASM_BR, which is not okay.

See: https://github.com/ClangBuiltLinux/linux/issues/1125

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

3 years ago[flang][openacc] Fix device_num and device_type clauses for init directive
Valentin Clement [Wed, 7 Oct 2020 01:26:13 +0000 (21:26 -0400)]
[flang][openacc] Fix device_num and device_type clauses for init directive

This patch fix the device_num and device_type clauses used in the init clause. device_num was not
spelled correctly in the parser and was to restrictive with scalarIntConstantExpr instead of scalarIntExpr.
device_type is now taking a list of ScalarIntExpr.

Reviewed By: kiranchandramohan

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

3 years ago[Attributor] Use smarter way to determine alignment of GEPs
Johannes Doerfert [Sun, 13 Sep 2020 04:41:48 +0000 (23:41 -0500)]
[Attributor] Use smarter way to determine alignment of GEPs

Use same logic existing in other places to deal with base case GEPs.

Add the original Attributor talk example.

3 years ago[Attributor] Ignore read accesses to constant memory
Johannes Doerfert [Wed, 9 Sep 2020 05:41:46 +0000 (00:41 -0500)]
[Attributor] Ignore read accesses to constant memory

The old function attribute deduction pass ignores reads of constant
memory and we need to copy this behavior to replace the pass completely.
First step are constant globals. TBAA can also describe constant
accesses and there are other possibilities. We might want to consider
asking the alias analyses that are available but for now this is simpler
and cheaper.

3 years ago[Attributor] Give up early on AANoReturn::initialize
Johannes Doerfert [Tue, 8 Sep 2020 00:56:51 +0000 (19:56 -0500)]
[Attributor] Give up early on AANoReturn::initialize

If the function is not assumed `noreturn` we should not wait for an
update to mark the call site as "may-return".

This has two kinds of consequences:
  - We have less iterations in many tests.
  - We have less deductions based on "known information" (since we ask
    earlier, point 1, and therefore assumed information is not "known"
    yet).
The latter is an artifact that we might want to tackle properly at some
point but which is not easily fixable right now.

3 years ago[lldb] Change the xcrun (fallback) logic in GetXcodeSDK
Jonas Devlieghere [Tue, 6 Oct 2020 22:12:23 +0000 (15:12 -0700)]
[lldb] Change the xcrun (fallback) logic in GetXcodeSDK

This changes the logic in GetXcodeSDK to find an SDK with xcrun. The
code now executes the following steps:

 1. If DEVELOPER_DIR is set in the environment, it invokes xcrun with
    the given developer dir. If this fails we stop and don't fall back.
 2. If the shlib dir is set and exists,it invokes xcrun with the
    developer dir corresponding to the shlib dir. If this fails we fall
    back to 3.
 3. We run xcrun without a developer dir.

The new behavior introduced in this patch is that we fall back to
running xcrun without a developer dir if running it based on the shlib
dir failed.

A situation where this matters is when you're running lldb from an Xcode
that has no SDKs and that is not xcode-selected. Based on lldb's shlib
dir pointing into this Xcode installation, it will do an xcrun with the
developer set to the Xcode without any SDKs which will fail. With this
patch, when that happens, we'll fall back to trying the xcode-selected
Xcode by running xcrun without a developer dir.

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

3 years ago[gn build] manually port 5e4409f308177
Nico Weber [Tue, 6 Oct 2020 22:43:12 +0000 (18:43 -0400)]
[gn build] manually port 5e4409f308177

3 years agoRelax FuseTensorReshapeOpAsproducer identity mapping constraint
Ahmed S. Taei [Tue, 6 Oct 2020 03:53:00 +0000 (03:53 +0000)]
Relax FuseTensorReshapeOpAsproducer identity mapping constraint

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

3 years agoFix out-of-tree clang build due to sysexits change
Dave Airlie [Tue, 6 Oct 2020 22:13:44 +0000 (18:13 -0400)]
Fix out-of-tree clang build due to sysexits change

The sysexists change broke clang building out of tree against llvm.

https://reviews.llvm.org/D88467

3 years ago[RuntimeDyld][COFF] Report fatal error on error, rather than emiting diagnostic.
Lang Hames [Tue, 6 Oct 2020 22:03:13 +0000 (15:03 -0700)]
[RuntimeDyld][COFF] Report fatal error on error, rather than emiting diagnostic.

Report a fatal error if an IMAGE_REL_AMD64_ADDR32NB cannot be applied due to an
out-of-range target. Previously we emitted a diagnostic to llvm::errs and
continued.

Patch by Dale Martin. Thanks Dale!

3 years agodocs: Emphasize ArrayRef over SmallVectorImpl
Duncan P. N. Exon Smith [Tue, 6 Oct 2020 22:09:19 +0000 (18:09 -0400)]
docs: Emphasize ArrayRef over SmallVectorImpl

The section on SmallVector has a note about preferring SmallVectorImpl
for APIs but doesn't mention ArrayRef. Although ArrayRef is discussed
elsewhere, let's re-emphasize here.

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

3 years agoReplace shadow space zero-out by madvise at mmap
Jianzhou Zhao [Mon, 5 Oct 2020 16:56:50 +0000 (16:56 +0000)]
Replace shadow space zero-out by madvise at mmap

After D88686, munmap uses MADV_DONTNEED to ensure zero-out before the
next access. Because the entire shadow space is created by MAP_PRIVATE
and MAP_ANONYMOUS, the first access is also on zero-filled values.

So it is fine to not zero-out data, but use madvise(MADV_DONTNEED) at
mmap. This reduces runtime
overhead.

Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D88755

3 years ago[CMake] Track TSan's dependency on C++ headers
Petr Hosek [Tue, 6 Oct 2020 18:32:57 +0000 (11:32 -0700)]
[CMake] Track TSan's dependency on C++ headers

TSan relies on C++ headers, so when libc++ is being built as part of
the runtimes build, include an explicit dependency on cxx-headers which
is the same approach that's already used for other sanitizers.

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

3 years ago[libc++] Add assert to check bounds in `constexpr string_view::operator[]`
Chris Palmer [Tue, 6 Oct 2020 17:01:50 +0000 (13:01 -0400)]
[libc++] Add assert to check bounds in `constexpr string_view::operator[]`

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

3 years ago[mlir] [sparse] convenience runtime support to read Matrix Market format
Aart Bik [Tue, 6 Oct 2020 19:15:36 +0000 (12:15 -0700)]
[mlir] [sparse] convenience runtime support to read Matrix Market format

Setting up input data for benchmarks and integration tests can be tedious in
pure MLIR. With more sparse tensor work planned, this convenience library
simplifies reading sparse matrices in the popular Matrix Market Exchange
Format (see https://math.nist.gov/MatrixMarket). Note that this library
is *not* part of core MLIR. It is merely intended as a convenience library
for benchmarking and integration testing.

Reviewed By: penpornk

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

3 years agoRemove unneeded "allow-unregistered-dialect" from shape-type-conversion.mlir test...
Mehdi Amini [Tue, 6 Oct 2020 20:11:39 +0000 (20:11 +0000)]
Remove unneeded "allow-unregistered-dialect" from shape-type-conversion.mlir test (NFC)

3 years agoRevert [lit] Support running tests on Windows without GnuWin32
Alexandre Ganea [Tue, 6 Oct 2020 19:07:42 +0000 (15:07 -0400)]
Revert [lit] Support running tests on Windows without GnuWin32

This reverts b3418cb4eb1456c41606f4621dcfa362fe54183c and d12ae042e17b27ebc8d2b5ae3d8dd5f88384d093

This breaks some external bots, see discussion in https://reviews.llvm.org/D84380

In the meanwhile, please use `cmake -DLLVM_LIT_TOOLS_DIR="C:/Program Files/Git/usr/bin"` or add it to %PATH%.

3 years ago[libc++] Add a script to setup CI on macOS nodes
Louis Dionne [Tue, 6 Oct 2020 18:13:55 +0000 (14:13 -0400)]
[libc++] Add a script to setup CI on macOS nodes

3 years ago[c++17] Implement P0145R3 during constant evaluation.
Richard Smith [Tue, 6 Oct 2020 00:52:23 +0000 (17:52 -0700)]
[c++17] Implement P0145R3 during constant evaluation.

Ensure that we evaluate assignment and compound-assignment
right-to-left, and array subscripting left-to-right.

Fixes PR47724.

This is a re-commit of ded79be, reverted in 37c74df, with a fix and test
for the crasher bug previously introduced.

3 years ago[NFC][MC] Type uses of MCRegUnitIterator as MCRegister
Mircea Trofin [Mon, 5 Oct 2020 23:49:29 +0000 (16:49 -0700)]
[NFC][MC] Type uses of MCRegUnitIterator as MCRegister

This is one of many subsequent similar changes. Note that we're ok with
the parameter being typed as MCPhysReg, as MCPhysReg -> MCRegister is a
correct conversion; Register -> MCRegister assumes the former is indeed
physical, so we stop relying on the implicit conversion and use the
explicit, value-asserting asMCReg().

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

3 years ago[mlir][spirv] Add Vector to SPIR-V conversion pass
Thomas Raoux [Tue, 6 Oct 2020 18:35:14 +0000 (11:35 -0700)]
[mlir][spirv] Add Vector to SPIR-V conversion pass

Add conversion pass for Vector dialect to SPIR-V dialect and add some simple
conversion pattern for vector.broadcast, vector.insert, vector.extract.

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

3 years ago[AMDGPU] Fix remaining kernel descriptor test
Scott Linder [Tue, 6 Oct 2020 18:45:04 +0000 (18:45 +0000)]
[AMDGPU] Fix remaining kernel descriptor test

Follow up on e4a9e4ef554a to fix a test I missed in the original patch.
Committed as obvious.

3 years ago[NFC][flang] Add the header file Todo.h. This file is being upstreamed to satisfy...
Eric Schweitz [Tue, 6 Oct 2020 16:31:16 +0000 (09:31 -0700)]
[NFC][flang] Add the header file Todo.h. This file is being upstreamed to satisfy dependencies and enable continued progress on lowering of OpenMP, OpenACC, etc.

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

3 years ago[SystemZ][z/OS] Set default alignment rules for z/OS target
Fanbo Meng [Tue, 6 Oct 2020 18:19:18 +0000 (14:19 -0400)]
[SystemZ][z/OS] Set default alignment rules for z/OS target

Update RUN line to fix lit failure

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

3 years ago[mlir][Linalg] Implement tiling on tensors
Nicolas Vasilache [Tue, 6 Oct 2020 17:48:56 +0000 (17:48 +0000)]
[mlir][Linalg] Implement tiling on tensors

This revision implements tiling on tensors as described in:
https://llvm.discourse.group/t/an-update-on-linalg-on-tensors/1878/4

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

3 years ago[mlir][spirv] Fix extended insts deserialization generation
Konrad Dobros [Tue, 6 Oct 2020 17:33:41 +0000 (13:33 -0400)]
[mlir][spirv] Fix extended insts deserialization generation

This change replaces container used for storing temporary
strings for generated code to std::list.
SmallVector may reallocate internal data, which will invalidate
references when more than one extended instruction set is
generated.

Reviewed By: mravishankar, antiagainst

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

3 years ago[AMDGPU] Emit correct kernel descriptor on big-endian hosts
Scott Linder [Mon, 5 Oct 2020 22:45:35 +0000 (22:45 +0000)]
[AMDGPU] Emit correct kernel descriptor on big-endian hosts

Previously we wrote multi-byte values out as-is from host memory. Use
the `emitIntN` helpers in `MCStreamer` to produce a valid descriptor
irrespective of the host endianness.

Reviewed By: arsenm, rochauha

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

3 years ago[mlir][vector] Fold extractOp coming from broadcastOp
Thomas Raoux [Tue, 6 Oct 2020 16:56:35 +0000 (09:56 -0700)]
[mlir][vector] Fold extractOp coming from broadcastOp

Combine ExtractOp with scalar result with BroadcastOp source. This is useful to
be able to incrementally convert degenerated vector of one element into scalar.

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

3 years ago[AMDGPU] Create isGFX9Plus utility function
Stanislav Mekhanoshin [Tue, 6 Oct 2020 17:05:43 +0000 (10:05 -0700)]
[AMDGPU] Create isGFX9Plus utility function

Introduce a utility function to make it more
convenient to write code that is the same on
the GFX9 and GFX10 subtargets.

Use isGFX9Plus in the AsmParser for AMDGPU.

Authored By: Joe_Nash

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

3 years ago[SystemZ][z/OS] Set default alignment rules for z/OS target
Fanbo Meng [Tue, 6 Oct 2020 17:13:01 +0000 (13:13 -0400)]
[SystemZ][z/OS] Set default alignment rules for z/OS target

Set the default alignment control variables for z/OS target and add test case for alignment rules on z/OS.

Reviewed By: abhina.sreeskantharajan

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

3 years ago[X86][SSE] combineX86ShuffleChain add 'CanonicalizeShuffleInput' helper. NFCI.
Simon Pilgrim [Tue, 6 Oct 2020 16:32:35 +0000 (17:32 +0100)]
[X86][SSE] combineX86ShuffleChain add 'CanonicalizeShuffleInput' helper. NFCI.

As part of PR45974, we're getting closer to not creating 'padded' vectors on-the-fly in combineX86ShufflesRecursively, and only pad the source inputs if we have a definite match inside combineX86ShuffleChain.

At the moment combineX86ShuffleChain just has to bitcast an input to the correct shuffle type, but eventually we'll need to pad them as well. So, move the bitcast into a 'CanonicalizeShuffleInput helper for now, making the diff for future padding support a lot smaller.

3 years ago[AMDGPU] Remove SIInstrInfo::calculateLDSSpillAddress
Sebastian Neubauer [Tue, 6 Oct 2020 15:08:34 +0000 (17:08 +0200)]
[AMDGPU] Remove SIInstrInfo::calculateLDSSpillAddress

This function does not seem to be used anymore.

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

3 years ago[MemCpyOpt] Use dereferenceable pointer helper
Nikita Popov [Sun, 4 Oct 2020 19:03:02 +0000 (21:03 +0200)]
[MemCpyOpt] Use dereferenceable pointer helper

The call slot optimization has some home-grown code for checking
whether the destination is dereferenceable. Replace this with the
generic isDereferenceableAndAlignedPointer() helper.

I'm not checking alignment here, because that is currently handled
separately and may be an enforced alignment for allocas. The clean
way of integrating that part would probably be to accept a callback
in isDereferenceableAndAlignedPointer() for the actual isAligned check,
which would then have a chance to use an enforced alignment instead.

This allows the destination to be a GEP (among other things), though
the two open TODOs may prevent it from working in practice.

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

3 years ago[MemCpyOpt] Check for throwing calls during call slot optimization
Nikita Popov [Sun, 4 Oct 2020 16:04:28 +0000 (18:04 +0200)]
[MemCpyOpt] Check for throwing calls during call slot optimization

When performing call slot optimization for a non-local destination,
we need to check whether there may be throwing calls between the
call and the copy. Otherwise, the early write to the destination
may be observable by the caller.

This was already done for call slot optimization of load/store,
but not for memcpys. For the sake of clarity, I'm moving this check
into the common optimization function, even if that does need an
additional instruction scan for the load/store case.

As efriedma pointed out, this check is not sufficient due to
potential accesses from another thread. This case is left as a TODO.

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

3 years ago[MemCpyOpt] Add separate statistic for call slot optimization (NFC)
Nikita Popov [Tue, 6 Oct 2020 16:14:10 +0000 (18:14 +0200)]
[MemCpyOpt] Add separate statistic for call slot optimization (NFC)

3 years ago[libc++] Check _LIBCPP_USE_CLOCK_GETTIME before using clock_gettime
Hafiz Abid Qadeer [Mon, 5 Oct 2020 21:28:25 +0000 (17:28 -0400)]
[libc++] Check _LIBCPP_USE_CLOCK_GETTIME before using clock_gettime

The clock_gettime function is available when _POSIX_TIMERS is defined.
We check for this and set _LIBCPP_USE_CLOCK_GETTIME accordingly since
59b3102739c. But check for _LIBCPP_USE_CLOCK_GETTIME was removed in
babd3aefc91. As a result, code is now trying to use clock_gettime even
on platforms where it is not available and it is causing build failure
with newlib.

This patch restores the checks to fix this.

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

3 years ago[flang] Track CHARACTER length better in TypeAndShape
peter klausler [Thu, 1 Oct 2020 18:46:24 +0000 (11:46 -0700)]
[flang] Track CHARACTER length better in TypeAndShape

CHARACTER length expressions were not always being
captured or computed as part of procedure "characteristics",
leading to test failures due to an inability to compute
memory size expressions accurately.

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

3 years ago[APIntTest] Extend extractBits to check 'lshr+trunc' pattern for each case as well.
Simon Pilgrim [Tue, 6 Oct 2020 15:30:09 +0000 (16:30 +0100)]
[APIntTest] Extend extractBits to check 'lshr+trunc' pattern for each case as well.

Noticed while triaging PR47731 that we don't have great coverage for such patterns.

3 years ago[libc++] Allow retries in two flaky tests
Louis Dionne [Tue, 6 Oct 2020 15:27:57 +0000 (11:27 -0400)]
[libc++] Allow retries in two flaky tests

3 years ago[X86] .code16: temporarily set Mode32Bit when matching an instruction with the data32...
Fangrui Song [Tue, 6 Oct 2020 15:26:12 +0000 (08:26 -0700)]
[X86] .code16: temporarily set Mode32Bit when matching an instruction with the data32 prefix

PR47632

This allows MC to match `data32 ...` as one instruction instead of two (data32 without insn + insn).

The compatibility with GNU as improves: `data32 ljmp` will be matched as ljmpl.
`data32 lgdt 4(%eax)` will be matched as `lgdtl` (prefixes: 0x67 0x66, instead
of 0x66 0x67).

GNU as supports many other `data32 *w` as `*l`. We currently just hard code
`data32 callw` and `data32 ljmpw`.  Generalizing the suffix replacement is
tricky and requires a think about the "bwlq" appending suffix rules in MatchAndEmitATTInstruction.

Reviewed By: craig.topper

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

3 years ago[HIP] NFC Add comments to cmath functions
Aaron En Ye Shi [Tue, 6 Oct 2020 15:26:56 +0000 (15:26 +0000)]
[HIP] NFC Add comments to cmath functions

Add missing comments to cmath functions.

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

3 years ago[HIP] NFC properly reference Differential Revision
Aaron En Ye Shi [Tue, 6 Oct 2020 15:19:00 +0000 (15:19 +0000)]
[HIP] NFC properly reference Differential Revision

Committed [HIP] Restructure hip headers to add cmath
with typo in commit message. Should be Differential
Revision instead of Review. Using this to close the
diff.

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

3 years ago[SimplifyLibCalls] Optimize mempcpy_chk to mempcpy
Dávid Bolvanský [Mon, 5 Oct 2020 20:16:59 +0000 (22:16 +0200)]
[SimplifyLibCalls] Optimize mempcpy_chk to mempcpy

3 years ago[gn build] Port aa2b593f149
LLVM GN Syncbot [Tue, 6 Oct 2020 14:49:44 +0000 (14:49 +0000)]
[gn build] Port aa2b593f149

3 years ago[HIP] Restructure hip headers to add cmath
Aaron En Ye Shi [Thu, 1 Oct 2020 21:43:52 +0000 (21:43 +0000)]
[HIP] Restructure hip headers to add cmath

Separate __clang_hip_math.h header into __clang_hip_cmath.h
and __clang_hip_math.h. Improve the math function definition,
and add missing definitions or declarations. Add missing
overloads.

Reviewed By: tra, JonChesterfield

Differential Review: https://reviews.llvm.org/D88837

3 years ago[BPF][NewPM] Make BPFTargetMachine properly adjust NPM optimizer pipeline
Arthur Eubanks [Mon, 5 Oct 2020 22:17:12 +0000 (15:17 -0700)]
[BPF][NewPM] Make BPFTargetMachine properly adjust NPM optimizer pipeline

This involves porting BPFAbstractMemberAccess and BPFPreserveDIType to
NPM, then adding them BPFTargetMachine::registerPassBuilderCallbacks
(the NPM equivalent of adjustPassManager()).

Reviewed By: yonghong-song, asbirlea

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

3 years ago[test][InstCombine][NewPM] Fix InstCombine tests under NPM
Arthur Eubanks [Wed, 23 Sep 2020 22:11:40 +0000 (15:11 -0700)]
[test][InstCombine][NewPM] Fix InstCombine tests under NPM

Some of these depended on analyses being present that aren't provided
automatically in NPM.

early_dce_clobbers_callgraph.ll was previously inlining a noinline function?

cast-call-combine.ll relied on the legacy always-inline pass being a
CGSCC pass and getting rerun.

Reviewed By: asbirlea

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

3 years ago[test][NewPM] Make dead-uses.ll work under NPM
Arthur Eubanks [Tue, 22 Sep 2020 22:18:55 +0000 (15:18 -0700)]
[test][NewPM] Make dead-uses.ll work under NPM

This one is weird...

globals-aa needs to be already computed at licm, or else a function pass
can't run a module analysis and won't have access to globals-aa.
But the globals-aa result is impacted by instcombine in a way that
affects what the test is expecting. If globals-aa is computed before
instcombine, it is cached and globals-aa used in licm won't contain the
necessary info provided by instcombine.
Another catch is that if we don't invalidate AAManager, it will use the
cached AAManager that instcombine requested, which may not contain
globals-aa. So we have to invalidate<aa> so that licm can recompute
an AAManager with the globals-aa created by the require<globals-aa>.

This is essentially the problem described in https://reviews.llvm.org/D84259.

Reviewed By: asbirlea

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

3 years ago[Attributor][FIX] Move assertion to make it not trivially fail
Johannes Doerfert [Wed, 9 Sep 2020 21:08:20 +0000 (16:08 -0500)]
[Attributor][FIX] Move assertion to make it not trivially fail

The idea of this assertion was to check the simplified value before we
assign it, not after, which caused this to trivially fail all the time.

3 years ago[Attributor][FIX] Dead return values are not `noundef`
Johannes Doerfert [Wed, 9 Sep 2020 01:18:54 +0000 (20:18 -0500)]
[Attributor][FIX] Dead return values are not `noundef`

When we assume a return value is dead we might still visit return
instructions via `Attributor::checkForAllReturnedValuesAndReturnInsts(..)`.
When we do so the "returned value" is potentially simplified to `undef`
as it is the assumed "returned value". This is a problem if there was a
preexisting `noundef` attribute that will only be removed as we manifest
the `undef` return value. We should not use this combination to derive
`unreachable` though. Two test cases fixed.

3 years ago[Attributor][NFC] Ignore benign uses in AAMemoryBehaviorFloating
Johannes Doerfert [Mon, 7 Sep 2020 22:55:05 +0000 (17:55 -0500)]
[Attributor][NFC] Ignore benign uses in AAMemoryBehaviorFloating

In AAMemoryBehaviorFloating we used to track benign uses in a SetVector.
With this change we look through benign uses eagerly to reduce the
number of elements (=Uses) we look at during an update.

The test does actually not fail prior to this commit but I already wrote
it so I kept it.