platform/upstream/llvm.git
2 years agoRevert "[Attr] support btf_type_tag attribute"
Martin Storsjö [Fri, 5 Nov 2021 08:12:20 +0000 (10:12 +0200)]
Revert "[Attr] support btf_type_tag attribute"

This reverts commits 737e4216c537c33aab8ec51880f06b8a54325b94 and
ce7ac9e66aba2b937b3d3b5505ce6cc75dcc56ac.

After those commits, the compiler can crash with a reduced
testcase like this:

$ cat reduced.c
void a(*);
void a() {}
$ clang -c reduced.c -O2 -g

2 years ago[libunwind] Try to add --unwindlib=none while configuring and building libunwind
Martin Storsjö [Fri, 10 Sep 2021 19:14:48 +0000 (22:14 +0300)]
[libunwind] Try to add --unwindlib=none while configuring and building libunwind

If Clang is set up to link directly against libunwind (via the
--unwindlib option, or the corresponding builtin default option),
configuring libunwind will fail while bootstrapping (before the
initial libunwind is built), because every cmake test will
fail due to -lunwind not being found, and linking the shared library
will fail similarly.

Check if --unwindlib=none is supported, and add it in that case.
Using check_c_compiler_flag on its own doesn't work, because that only
adds the tested flag to the compilation command, and if -lunwind is
missing, the linking step would still fail - instead try adding it
to CMAKE_REQUIRED_FLAGS and restore the variable if it doesn't work.

This avoids having to pass --unwindlib=none while building libunwind.

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

2 years ago[NPM] Fix bug in llvm/utils/reduce_pipeline.py
Markus Lavin [Fri, 5 Nov 2021 07:38:57 +0000 (08:38 +0100)]
[NPM] Fix bug in llvm/utils/reduce_pipeline.py

Last minute changes in https://reviews.llvm.org/D110908 unfortunately
introduced a bug wrt automatic pipeline expansion. This patch fixes that
as well as gets rid of a few redundant variables.

Reviewed By: aeubanks

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

2 years ago[asan] compiler-rt version of D113143
Vitaly Buka [Fri, 5 Nov 2021 06:50:57 +0000 (23:50 -0700)]
[asan] compiler-rt version of D113143

2 years agoFix some issues with the gdb pretty printers for llvm::Twine
David Blaikie [Fri, 5 Nov 2021 03:45:29 +0000 (20:45 -0700)]
Fix some issues with the gdb pretty printers for llvm::Twine

Still some pending bugs, but at least ironed some things out.

2 years ago[Preprocessor] Fix newline before/after _Pragma.
Michael Kruse [Fri, 5 Nov 2021 05:03:26 +0000 (00:03 -0500)]
[Preprocessor] Fix newline before/after _Pragma.

The PragmaAssumeNonNullHandler (and maybe others) passes an invalid
SourceLocation to its callback, hence PrintPreprocessedOutput does not
know how many lines to insert between the previous token and the
pragma and does nothing.

With this patch we instead assume that the unknown token is on the same
line as the previous such that we can call the procedure that also emits
semantically significant whitespace.

Fixes bug reported here: https://reviews.llvm.org/D104601#3105044

2 years ago[Preprocessor] Fix warning: left and right subexpressions are identical. NFCI.
Michael Kruse [Fri, 5 Nov 2021 05:13:49 +0000 (00:13 -0500)]
[Preprocessor] Fix warning: left and right subexpressions are identical. NFCI.

This is reported by msvc as
warning C6287: redundant code: the left and right subexpressions are identical

EmittedDirectiveOnThisLine implies EmittedTokensOnThisLine
making this an NFC change. To be on the safe side and because both of
them are checked at other places as well, we continue to check both.

Compiler warning reported here:
https://reviews.llvm.org/D104601#2957333

2 years ago[PowerPC] address post-commit comments for D106555; NFC
Chen Zheng [Fri, 5 Nov 2021 05:02:23 +0000 (05:02 +0000)]
[PowerPC] address post-commit comments for D106555; NFC

Address namanjai post commit comments.

2 years ago[lld-macho] Replace LC_LINKER_OPTION parsing
Keith Smiley [Fri, 5 Nov 2021 02:53:18 +0000 (19:53 -0700)]
[lld-macho] Replace LC_LINKER_OPTION parsing

This removes the tablegen based parsing of LC_LINKER_OPTION since it can
only actually contain a very small number of potential arguments. In our
project with tablegen this took 5 seconds before.

This replaces https://reviews.llvm.org/D113075

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

2 years ago[mlir][linalg][bufferize] Separate pass from ComprehensiveBufferize
Matthias Springer [Fri, 5 Nov 2021 04:55:47 +0000 (13:55 +0900)]
[mlir][linalg][bufferize] Separate pass from ComprehensiveBufferize

This commit separates the bufferization from the bufferization pass in Linalg. This allows other dialects to use ComprehensiveBufferize more easily.

This commit mainly moves files to a new directory and adds a new build target.

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

2 years ago[lld-macho] Fix an assertion failure when -u specifies an undefined section$start...
Fangrui Song [Fri, 5 Nov 2021 04:28:33 +0000 (21:28 -0700)]
[lld-macho] Fix an assertion failure when -u specifies an undefined section$start symbol

This matches ld64. Also improve the test for `-dead_strip`.

Reviewed By: #lld-macho, Jez Ng

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

2 years ago[X86][MS-InlineAsm][test] Add triple in ms-inline-asm-array.ll
Shengchen Kan [Fri, 5 Nov 2021 03:02:10 +0000 (11:02 +0800)]
[X86][MS-InlineAsm][test] Add triple in ms-inline-asm-array.ll

Fix the LIT test fail on Mac, which is reported in D113096.

2 years ago[mlir][linalg][bufferize][NFC] Simplify AllocationCallbacks
Matthias Springer [Fri, 5 Nov 2021 02:55:15 +0000 (11:55 +0900)]
[mlir][linalg][bufferize][NFC] Simplify AllocationCallbacks

AllocationCallbacks functions allocate/deallocate only. They no longer set the insertion point.

This is in preparation of decoupling ComprehensiveBufferize from the Linalg dialect.

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

2 years ago[mlir][linalg][bufferize] Decouple BufferizationAliasInfo
Matthias Springer [Fri, 5 Nov 2021 02:40:12 +0000 (11:40 +0900)]
[mlir][linalg][bufferize] Decouple BufferizationAliasInfo

Move dialect-specific and analysis-specific function out of BufferizationAliasInfo. BufferizationAliasInfo's only job now is to keep track of aliases.

This is in preparation of futher decoupling ComprehensiveBufferize from various dialects.

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

2 years ago[mlir][linalg][bufferize] Add isWritable to op interface
Matthias Springer [Fri, 5 Nov 2021 02:29:46 +0000 (11:29 +0900)]
[mlir][linalg][bufferize] Add isWritable to op interface

By default, OpResult buffers are writable. But there are ops (e.g., ConstantOp) for which this is not the case.

The purpose of this commit is to further decouple Comprehensive Bufferize from the Standard dialect.

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

2 years ago[OpaquePtr] Fix initialization-order-fiasco
Vitaly Buka [Fri, 5 Nov 2021 02:26:25 +0000 (19:26 -0700)]
[OpaquePtr] Fix initialization-order-fiasco

Asan detects it after D112732.

2 years ago[mlir][linalg][bufferize] Add MemCpyFn to AllocationCallbacks struct
Matthias Springer [Fri, 5 Nov 2021 01:42:59 +0000 (10:42 +0900)]
[mlir][linalg][bufferize] Add MemCpyFn to AllocationCallbacks struct

This in preparation of decoupling BufferizableOpInterface, Comprehensive Bufferize and dialects.

The goal of this CL is to make `getResultBuffer` (and other `bufferize` functions) independent of `LinalgOps`.

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

2 years ago[NFC] Don't set rlimit in test with MSAN
Vitaly Buka [Fri, 5 Nov 2021 01:08:11 +0000 (18:08 -0700)]
[NFC] Don't set rlimit in test with MSAN

2 years ago[NFC] Disabled few tests with MemoryWithOrigins
Vitaly Buka [Fri, 5 Nov 2021 01:07:15 +0000 (18:07 -0700)]
[NFC] Disabled few tests with MemoryWithOrigins

They pass regular MemorySanitizer, but hang with origin
tracking.

2 years ago[X86][MS-InlineAsm] Add constraint *m for memory access w/ global var
Shengchen Kan [Wed, 3 Nov 2021 08:52:55 +0000 (16:52 +0800)]
[X86][MS-InlineAsm] Add constraint *m for memory access w/ global var

Constraint `*m` should be used when the address of a variable is passed
as a value. And the constraint is missing for MS inline assembly when sth
is written to the address of the variable.

The missing would cause FE delete the definition of the static varible,
and then result in "undefined reference to xxx" issue.

Reviewed By: xiangzhangllvm

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

2 years ago[lld-macho] Clear resolvedReads cache
Keith Smiley [Thu, 4 Nov 2021 16:42:57 +0000 (09:42 -0700)]
[lld-macho] Clear resolvedReads cache

https://reviews.llvm.org/D113153#3108083

smeenai, int3

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

2 years ago[mlir][linalg][bufferize] Remove redundant methods from op interface
Matthias Springer [Fri, 5 Nov 2021 00:35:14 +0000 (09:35 +0900)]
[mlir][linalg][bufferize] Remove redundant methods from op interface

These two methods are redundant and removed:
* `bufferizesToAliasOnly`: If not `bufferizesToMemoryRead` and not `bufferizesToMemoryWrite` but `getAliasingOpResult` returns a non-null value, we know that this OpOperand is alias-only. This method now has a default implementation and does not have to be implemented.
* `getInplaceableOpResult`: The analysis does not differentiate between "inplaceable" and "aliasing". The only thing that matters is whether or not OpOperand and OpResult are aliasing. That is the key property that makes buffer copies necessary.

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

2 years ago[mlir][sparse] implement full reduction "scalarization" across loop nests
Aart Bik [Wed, 3 Nov 2021 02:58:33 +0000 (19:58 -0700)]
[mlir][sparse] implement full reduction "scalarization" across loop nests

The earlier reduction "scalarization" was only applied to a chain of
*innermost* and *for* loops. This revision generalizes this to any
nesting of for- and while-loops. This implies that reductions can be
implemented with a lot less load and store operations. The chaining
is implemented with a forest of yield statements (but not as bad as
when we would also include the while-induction).

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

Reviewed By: bixia

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

2 years ago[ASan] Added stack safety support in address sanitizer.
Kirill Stoimenov [Thu, 4 Nov 2021 22:05:04 +0000 (15:05 -0700)]
[ASan] Added stack safety support in address sanitizer.

 Added and implemented -asan-use-stack-safety flag, which control if ASan would use the Stack Safety results to emit less code for operations which are marked as 'safe' by the static analysis.

Reviewed By: vitalybuka

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

2 years ago[NewPM] Make eager analysis invalidation per-adaptor
Arthur Eubanks [Wed, 3 Nov 2021 22:45:30 +0000 (15:45 -0700)]
[NewPM] Make eager analysis invalidation per-adaptor

Follow-up change to D111575.
We don't need eager invalidation on every adaptor. Most notably,
adaptors running passes that use very few analyses, or passes that
purely invalidate specific analyses.

Also allow testing of this via a pipeline string
"function<eager-inv>()".

The compile time/memory impact of this is very comparable to D111575.
https://llvm-compile-time-tracker.com/compare.php?from=9a2eec512a29df45c90c2fcb741e9d5c693b1383&to=b9f20bcdea138060967d95a98eab87ce725b22bb&stat=instructions

Reviewed By: nikic

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

2 years agoBPF: Support btf_type_tag attribute
Yonghong Song [Mon, 18 Oct 2021 04:26:15 +0000 (21:26 -0700)]
BPF: Support btf_type_tag attribute

A new kind BTF_KIND_TYPE_TAG is defined. The tags associated
with a pointer type are emitted in their IR order as modifiers.
For example, for the following declaration:
  int __tag1 * __tag1 __tag2 *g;
The BTF type chain will look like
  VAR(g) -> __tag1 --> __tag2 -> pointer -> __tag1 -> pointer -> int
In the above "->" means BTF CommonType.Type which indicates
the point-to type.

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

2 years agoCanonicalization for add to no-op if one of the inputs is zero
not-jenni [Thu, 4 Nov 2021 23:52:24 +0000 (16:52 -0700)]
Canonicalization for add to no-op if one of the inputs is zero

Reviewed By: rsuderman

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

2 years ago[libcxxabi] Fix NO_THREADS version of test_exception_storage.pass.cpp
Daniel McIntosh [Wed, 11 Aug 2021 18:54:16 +0000 (14:54 -0400)]
[libcxxabi] Fix NO_THREADS version of test_exception_storage.pass.cpp

`thread_code` returns param, which for NO_THREADS is going to be
`&thread_globals`. Thus, the return value will never be null. The test
was probably meant to check if `*thread_code(&thread_globals) == 0`.
However, to avoid the extra cast, and to bring the NO_THREADS version
more in line with the regular version of the test, this changes it to
check if thread_globals == 0 directly.

Reviewed By: ldionne, #libc_abi

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

2 years agoBPF: fix a buildbot test failure
Yonghong Song [Thu, 4 Nov 2021 23:06:12 +0000 (16:06 -0700)]
BPF: fix a buildbot test failure

Commit 737e4216c537 ("[Attr] support btf_type_tag attribute")
added btf_type_tag support in llvm. Buildbot reported a
failure with attr-btf_type_tag.ll.

  ; CHECK-NEXT: DW_AT_type (0x[[T1:[0-9]+]] "int ***")

  <stdin>:15:2: note: possible intended match here
   DW_AT_type (0x0000002f "int ***")

The pattern [0-9]+ is not enough to match 0000002f, we
need [0-9a-f]+. This patch fixed the issue.

2 years ago[OpenMP] Build device runtimes for sm_86
Johannes Doerfert [Wed, 3 Nov 2021 15:28:11 +0000 (10:28 -0500)]
[OpenMP] Build device runtimes for sm_86

Reviewed By: carlo.bertolli

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

2 years ago[OpenMP] Introduce the keepAlive function into the old device RT
Johannes Doerfert [Wed, 3 Nov 2021 15:26:34 +0000 (10:26 -0500)]
[OpenMP] Introduce the keepAlive function into the old device RT

Reviewed By: ye-luo

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

2 years ago[OpenMP][NFCI] Cleanup new device RT mapping interface
Johannes Doerfert [Wed, 3 Nov 2021 15:06:57 +0000 (10:06 -0500)]
[OpenMP][NFCI] Cleanup new device RT mapping interface

Minimize the `impl` interface and clean up some uses of mapping
functions.

Reviewed By: jhuber6

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

2 years ago[indvars] Use loop guards when canonicalizing exit conditions
Philip Reames [Thu, 4 Nov 2021 22:21:39 +0000 (15:21 -0700)]
[indvars] Use loop guards when canonicalizing exit conditions

This extends the logic in canonicalizeExitConditions to use loop guards to specialize the SCEV of the loop invariant term before quering it's range.

2 years ago[NewPM] Use the default AA pipeline by default
Arthur Eubanks [Thu, 4 Nov 2021 18:23:46 +0000 (11:23 -0700)]
[NewPM] Use the default AA pipeline by default

We almost always want to use the default AA pipeline. It's very easy for
users of PassBuilder to forget to customize the AAManager to use the
default AA pipeline (for example, the NewPM C API forgets to do this).

If somebody wants a custom AA pipeline, similar to what is being done
now with the default AA pipeline registration, they can

  FAM.registerPass([&] { return std::move(MyAA); });

before calling

  PB.registerFunctionAnalyses(FAM);

For example, LTOBackend.cpp and NewPMDriver.cpp do this.

Reviewed By: asbirlea

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

2 years ago[ORC] Add a utility for adding missing "self" relocations to a Symbol
Ben Langmuir [Tue, 2 Nov 2021 17:49:08 +0000 (10:49 -0700)]
[ORC] Add a utility for adding missing "self" relocations to a Symbol

If a tool wants to introduce new indirections via stubs at link-time in
ORC, it can cause fidelity issues around the address of the function if
some references to the function do not have relocations. This is known
to happen inside the body of the function itself on x86_64 for example,
where a PC-relative address is formed, but without a relocation.

```
_foo:
  leaq -7(%rip), %rax ## form pointer to '_foo' without relocation

_bar:
  leaq (%rip), %rax ##  uses X86_64_RELOC_SIGNED to '_foo'
```

The consequence of introducing a stub for such a function at link time
is that if it forms a pointer to itself without relocation, it will not
have the same value as a pointer from outside the function. If the
function pointer is used as a key, this can cause problems.

This utility provides best-effort support for adding such missing
relocations using MCDisassembler and MCInstrAnalysis to identify the
problematic instructions. Currently it is only implemented for x86_64.

Note: the related issue with call/jump instructions is not handled
here, only forming function pointers.

rdar://83514317

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

2 years ago[libcxx][NFC] tidy up money_get::__do_get's sign parsing
Daniel McIntosh [Fri, 16 Jul 2021 17:39:31 +0000 (13:39 -0400)]
[libcxx][NFC] tidy up money_get::__do_get's sign parsing

Same logic, but much easier to read this way

Reviewed By: ldionne, #libc, Mordante

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

2 years agoDebugInfo: Fix incorrect line table lookup when resolving decl_file from a split...
David Blaikie [Thu, 4 Nov 2021 17:09:53 +0000 (10:09 -0700)]
DebugInfo: Fix incorrect line table lookup when resolving decl_file from a split unit

Specifically in DWARFv5 the unit for the line table entry was correct
but the context was incorrect - leading to looking up .debug_line_str in
the dwp instead of the executable.

(perhaps we could/should remove the context pointer entirely, and rely
on the one in the unit... I might try that as a separate follow-up
commit)

2 years ago[indvars] Allow rotation (narrowing) of exit test when discovering trip count
Philip Reames [Thu, 4 Nov 2021 21:46:20 +0000 (14:46 -0700)]
[indvars] Allow rotation (narrowing) of exit test when discovering trip count

This relaxes the one-use requirement on the rotation transform specifically for the case where we know we're zexting an IV of the loop.  This allows us to discover trip count information in SCEV, which seems worth a single extra loop invariant truncate.  Honestly, I'd prefer if SCEV could just compute the trip count directly (e.g. D109457), but this unblocks practical benefit.

2 years ago[mlir][core] Slightly improved attribute lookup
Mogball [Thu, 4 Nov 2021 20:34:01 +0000 (20:34 +0000)]
[mlir][core] Slightly improved attribute lookup

- String binary search does 1 less string comparison
- Identifier linear scan on large attribute list is switched to string binary search

Reviewed By: rriddle

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

2 years ago[OpenMP] Add parsing/sema/serialization for 'bind' clause.
Mike Rice [Wed, 3 Nov 2021 21:57:01 +0000 (14:57 -0700)]
[OpenMP] Add parsing/sema/serialization for 'bind' clause.

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

2 years ago[InstCombine] Precommit updated and-xor-or.ll tests. NFC.
Stanislav Mekhanoshin [Thu, 4 Nov 2021 21:26:42 +0000 (14:26 -0700)]
[InstCombine] Precommit updated and-xor-or.ll tests. NFC.

Tests for:

(~(a | b) & c) | ~(a | (b | c)) -> ~(a | b)
(~(a | b) & c) | ~(b | (a | c)) -> ~(a | b)

2 years ago[Attr] support btf_type_tag attribute
Yonghong Song [Fri, 1 Oct 2021 06:35:06 +0000 (23:35 -0700)]
[Attr] support btf_type_tag attribute

This patch added clang codegen and llvm support
for btf_type_tag support. Currently, btf_type_tag
attribute info is preserved in DebugInfo IR only for
pointer types associated with typedef, global variable
and function declaration. Eventually, such information
is emitted to dwarf.

The following is an example:
  $ cat test.c
  #define __tag __attribute__((btf_type_tag("tag")))
  int __tag *g;
  $ clang -O2 -g -c test.c
  $ llvm-dwarfdump --debug-info test.o
  ...
  0x0000001e:   DW_TAG_variable
                  DW_AT_name      ("g")
                  DW_AT_type      (0x00000033 "int *")
                  DW_AT_external  (true)
                  DW_AT_decl_file ("/home/yhs/test.c")
                  DW_AT_decl_line (2)
                  DW_AT_location  (DW_OP_addr 0x0)

  0x00000033:   DW_TAG_pointer_type
                  DW_AT_type      (0x00000042 "int")

  0x00000038:     DW_TAG_LLVM_annotation
                    DW_AT_name    ("btf_type_tag")
                    DW_AT_const_value     ("tag")

  0x00000041:     NULL

  0x00000042:   DW_TAG_base_type
                  DW_AT_name      ("int")
                  DW_AT_encoding  (DW_ATE_signed)
                  DW_AT_byte_size (0x04)

  0x00000049:   NULL

Basically, a DW_TAG_LLVM_annotation tag will be inserted
under DW_TAG_pointer_type tag if that pointer has a btf_type_tag
associated with it.

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

2 years ago[indvars] Extend canonicalizeExitConditions to inverted operands
Philip Reames [Thu, 4 Nov 2021 21:19:24 +0000 (14:19 -0700)]
[indvars] Extend canonicalizeExitConditions to inverted operands

As discussed in the original reviews, but done in a follow on.

2 years ago[Clang][Attr] Support btf_type_tag attribute
Yonghong Song [Thu, 4 Nov 2021 20:23:19 +0000 (13:23 -0700)]
[Clang][Attr] Support btf_type_tag attribute

This patch introduced btf_type_tag attribute. The attribute
is a type attribute and intends to address the below
linux use cases.
    typedef int __user *__intp;
    int foo(int __user *arg, ...)
    static int do_execve(struct filename *filename,
        const char __user *const __user *__argv,
        const char __user *const __user *__envp)

Here __user in the kernel defined as
    __attribute__((noderef, address_space(__user)))
for sparse ([1]) type checking mode.

For normal clang compilation, we intend to replace it with
    __attribute__((btf_type_tag("user")))
and record such informaiton in dwarf and BTF so such
information later can be used in kernel for bpf verification
or for other tracing functionalities.

  [1] https://www.kernel.org/doc/html/v4.11/dev-tools/sparse.html

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

2 years ago[AMDGPU] Changes the AMDGPU_Gfx calling convention by making the SGPRs 4..29 callee...
Thomas Symalla [Mon, 25 Oct 2021 08:33:55 +0000 (10:33 +0200)]
[AMDGPU] Changes the AMDGPU_Gfx calling convention by making the SGPRs 4..29 callee-save. This is to avoid superfluous s_movs when executing amdgpu_gfx function calls as the callee is likely not going to change the argument values.

This patch changes the AMDGPU_Gfx calling convention. It defines the SGPR registers s[4:29] as callee-save and leaves some SGPRs usable for callers. The intention is to avoid unneccessary s_mov instructions for arguments the caller would otherwise save and restore in these registers.

Reviewed By: sebastian-ne

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

2 years ago[Support] Improve Caching conformance with Support library behavior
Noah Shutty [Thu, 4 Nov 2021 19:59:59 +0000 (12:59 -0700)]
[Support] Improve Caching conformance with Support library behavior

This diff makes several amendments to the local file caching mechanism
which was migrated from ThinLTO to Support in
rGe678c51177102845c93529d457b020f969125373 in response to follow-up
discussion on that commit.

Patch By: noajshu

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

2 years ago[Flang][OpenMP] Use the ultimate symbol in a call to the IsPointer function
Kiran Chandramohan [Thu, 4 Nov 2021 17:50:20 +0000 (17:50 +0000)]
[Flang][OpenMP] Use the ultimate symbol in a call to the IsPointer function

The IsPointer check currently fails for host-associated symbols in OpenMP
regions. This causes some failures in semantic checks for pointer association
in an OpenMP region. Fix is to use the ultimate symbol in the call to the
IsPointer function in CheckPointerAssignment function in
lib/Semantics/pointer-assignment.cpp.

Reviewed By: klausler, peixin

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

2 years ago[X86][SSE] Regenerate vector funnel shift tests
Simon Pilgrim [Thu, 4 Nov 2021 16:02:25 +0000 (16:02 +0000)]
[X86][SSE] Regenerate vector funnel shift tests

2 years ago[mlir][ods] Op::verify should not call OpAdaptor::verify
Mogball [Wed, 3 Nov 2021 17:06:14 +0000 (17:06 +0000)]
[mlir][ods] Op::verify should not call OpAdaptor::verify

OpAdaptor::verify performs string lookups on an attribute dictionary. By
calling OpAdaptor::verify, Op::verify is not able to use cached attribute
identifiers for faster lookups.

Reviewed By: jpienaar, rriddle

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

2 years ago[llvm][adt] make_first_range returning reference to temporary
Mogball [Wed, 3 Nov 2021 17:59:02 +0000 (17:59 +0000)]
[llvm][adt] make_first_range returning reference to temporary

Reviewed By: rriddle

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

2 years ago[ARM] Move VPTBlock pass after post-ra scheduling
David Green [Thu, 4 Nov 2021 18:42:12 +0000 (18:42 +0000)]
[ARM] Move VPTBlock pass after post-ra scheduling

Currently when tail predicating loops, vpt blocks need to be created
with the vctp predicate in case we need to revert to non-tail predicated
form. This has the unfortunate side effect of severely hampering post-ra
scheduling at times as the instructions are already stuck in vpt blocks,
not allowed to be independently ordered.

This patch addresses that by just moving the creation of VPT blocks
later in the pipeline, after post-ra scheduling has been performed. This
allows more optimal scheduling post-ra before the vpt blocks are
created, leading to more optimal tail predicated loops.

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

2 years ago[libc] add stpcpy and stpncpy
Michael Jones [Fri, 15 Oct 2021 22:11:37 +0000 (15:11 -0700)]
[libc] add stpcpy and stpncpy

Adds an implementation for stpcpy and stpncpy, which are posix extension
functions.

Reviewed By: sivachandra, lntue

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

2 years ago[WebAssembly] Fix debug locations for ExplicitLocals pass
Wouter van Oortmerssen [Mon, 25 Oct 2021 21:00:42 +0000 (14:00 -0700)]
[WebAssembly] Fix debug locations for ExplicitLocals pass

This is a reworked version of the reverted patch: https://reviews.llvm.org/D112487
Note that
a) it doesn't need the test changes anymore, and
b) I checked at least locally it passes other.test_pthread_lsan_leak

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

2 years ago[libc++] Improve no wide characters configuration.
Mark de Wever [Wed, 3 Nov 2021 18:25:20 +0000 (19:25 +0100)]
[libc++] Improve no wide characters configuration.

When wide characters are supported libc++ manually translates a
`narrow non-breaking space` and a `non-breaking space` to a space.
This behaviour wasn't available when wide characters were disabled.
This enables an emulation for that configuration.

Updating the libc++ Docker image to Ubuntu Focal caused some breakage.
This was temporary disabled in D112737. This re-enables four of these
tests.

Reviewed By: ldionne, #libc

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

2 years ago[libc++] Remove non-atomic "platform" semaphore implementations.
Arthur O'Dwyer [Mon, 20 Sep 2021 22:03:49 +0000 (18:03 -0400)]
[libc++] Remove non-atomic "platform" semaphore implementations.

These can't be made constexpr-constructible (constinit'able),
so they aren't C++20-conforming. Also, the platform versions are
going to be bigger than the atomic/futex version, so we'd have
the awkward situation that `semaphore<42>` could be bigger than
`semaphore<43>`, and that's just silly.

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

2 years ago[mlir] Handle StringAttr in SparseElementsAttr::getZeroAttr.
Chia-hung Duan [Thu, 4 Nov 2021 18:11:50 +0000 (18:11 +0000)]
[mlir] Handle StringAttr in SparseElementsAttr::getZeroAttr.

Reviewed By: rriddle

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

2 years ago[flang][flang-omp-report] Add flang-omp-report summarising script
Josh Mottley [Thu, 21 Oct 2021 14:39:05 +0000 (14:39 +0000)]
[flang][flang-omp-report] Add flang-omp-report summarising script

The flang plugin ``flang-omp-report`` takes one fortran file in and returns a
YAML report file of the input file. This becomes an issue when you want to
analyse an entire project into one final report.
The purpose of this Python script is to generate a final YAML
report from all of the files generated by ``flang-omp-report``. The report can
have (currently) 2 formats; summary and log. Summary focuses on "summarizing"
all constructs and there clauses from all YAML files with a corresponding "count"
for each. Log instead combines the generated YAML files into one report in a
"cleaner" format. (Pseudo) Examples can be found for both formats at the top of
the script.

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

Co-Authored by: Ivan Zhechev <ivan.zhechev@arm.com>

2 years ago[RISCV] Add another test case showing unnecessary vsetvli near mask instructions.
Craig Topper [Thu, 4 Nov 2021 16:59:05 +0000 (09:59 -0700)]
[RISCV] Add another test case showing unnecessary vsetvli near mask instructions.

This is similar to D112762, but the VL for the mask instruction
comes from a Phi node selecting between two vsetvlis.

2 years agoMake the BBAddrMap struct binary-format-agnostic.
Rahman Lavaee [Thu, 28 Oct 2021 00:00:27 +0000 (17:00 -0700)]
Make the BBAddrMap struct binary-format-agnostic.

The only binary-format-related field in the BBAddrMap structure is the function address (`Addr`), which will use uint64_t in 64B format and uint32_t in 32B format. This patch changes it to use uint64_t in both formats.
This allows non-templated use of the struct, at the expense of a marginal additional size overhead for the 32-bit format. The size of the BB address map section does not change.

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

2 years ago[RISCV] Rename some assembler mnemonic and intrinsic functions for RVV 1.0.
Zakk Chen [Thu, 4 Nov 2021 16:22:34 +0000 (09:22 -0700)]
[RISCV] Rename some assembler mnemonic and intrinsic functions for RVV 1.0.

Rename vpopc/vmandnot/vmornot to vcpop/vmandn/vmorn assembler mnemonic.

Reviewed By: frasercrmck, jrtc27, craig.topper

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

2 years ago[mlir][sparse] reject sparsity annotation in "scalar" tensors
Aart Bik [Thu, 4 Nov 2021 00:04:42 +0000 (17:04 -0700)]
[mlir][sparse] reject sparsity annotation in "scalar" tensors

Reviewed By: bixia

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

2 years ago[debugserver] Fix typo in DNBArchImplARM64
Jonas Devlieghere [Thu, 4 Nov 2021 16:43:31 +0000 (09:43 -0700)]
[debugserver] Fix typo in DNBArchImplARM64

rdar://85020754

2 years ago[docs] Update new builder instructions to default to building each change
Philip Reames [Thu, 4 Nov 2021 16:36:07 +0000 (09:36 -0700)]
[docs] Update new builder instructions to default to building each change

We generally prefer build bots which build each change as they come in as long as they can keep up. This generates much higher quality feedback to a developer. However, the code structure is such that we currently default new builders to batching.

This change updates the getting started instruction for a builder to explicitly advocate for not collapsing requests.

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

2 years ago[mlir][linalg] Add support for transitive fusion.
Tobias Gysi [Thu, 4 Nov 2021 15:51:58 +0000 (15:51 +0000)]
[mlir][linalg] Add support for transitive fusion.

Extend fusion on tensors to fuse producers greedily.

Reviewed By: nicolasvasilache, hanchung

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

2 years ago[NFC] Add size inference to to_vector
Geoffrey Martin-Noble [Mon, 1 Nov 2021 23:41:44 +0000 (16:41 -0700)]
[NFC] Add size inference to to_vector

A default calculated size for SmallVector was added in
https://reviews.llvm.org/D92522 after discussion in
https://groups.google.com/g/llvm-dev/c/Z-VwNCTRGSg, but to_vector still
requires an explicit size. This patch adds the default size to to_vector
as well, so that this case doesn't unnecessarily force users to pick an
arbitrary size.

Reviewed By: silvas, dblaikie

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

2 years ago[RISCV][ELF] Remove internal binutils relocations
Alex Bradbury [Thu, 4 Nov 2021 15:53:37 +0000 (15:53 +0000)]
[RISCV][ELF] Remove internal binutils relocations

These relocations have been removed from the psABI doc in
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/199. This
patch simply updates llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def
to match.

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

2 years ago[Hexagon] Use make_early_inc_range (NFC)
Kazu Hirata [Thu, 4 Nov 2021 15:51:05 +0000 (08:51 -0700)]
[Hexagon] Use make_early_inc_range (NFC)

2 years ago[libcxxabi][ARM] Make CXX_end_cleanup compatible with Armv6-M
Daniel Kiss [Thu, 4 Nov 2021 15:29:12 +0000 (16:29 +0100)]
[libcxxabi][ARM] Make CXX_end_cleanup compatible with Armv6-M

On Armv6-M the branch may not able to reach the _Unwind_Resume function because it's relocation(R_ARM_THM_JUMP11) is in -2048, 2047 range only.

Reviewed By: chill, stuij, lenary

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

2 years ago[Sema][NFC] Improve test coverage of builtin operators.
Clement Courbet [Thu, 4 Nov 2021 13:58:31 +0000 (14:58 +0100)]
[Sema][NFC] Improve test coverage of builtin operators.

In preparation for D112453.

Fix numbering of tests for [over.built]: 15->16, 16->17.

2 years agoRemove unused function from print-changed=dot-cfg code
Jamie Schmeiser [Thu, 4 Nov 2021 14:39:39 +0000 (10:39 -0400)]
Remove unused function from print-changed=dot-cfg code

Summary:
Remove unused function from print-changed=dot-cfg code to silence a
gcc compiler warning.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: uabelho(Mikael Holmen)
Differential Revision: https://reviews.llvm.org/D113188

2 years ago[NFC] Remove from UnivariateLinearPolyBase::getValue().
Sander de Smalen [Thu, 4 Nov 2021 13:49:10 +0000 (13:49 +0000)]
[NFC] Remove from UnivariateLinearPolyBase::getValue().

This interface should not have existed in the first place, let alone
be a public member.

It allows calling `ElementCount::get(..)->getValue()`, which is ambiguous.
The interfaces to be used are either getFixedValue() or getKnownMinValue().

2 years ago[lldb][NFC] StringRef-ify name param in CreateClassTemplateDecl
Raphael Isemann [Thu, 4 Nov 2021 14:23:08 +0000 (15:23 +0100)]
[lldb][NFC] StringRef-ify name param in CreateClassTemplateDecl

2 years ago[ARM] Regenerate shift-combine.ll test checks
Simon Pilgrim [Thu, 4 Nov 2021 14:18:43 +0000 (14:18 +0000)]
[ARM] Regenerate shift-combine.ll test checks

2 years ago[AMDGPU] Regenerate shift-and-i128-ubfe.ll test checks
Simon Pilgrim [Thu, 4 Nov 2021 14:18:02 +0000 (14:18 +0000)]
[AMDGPU] Regenerate shift-and-i128-ubfe.ll test checks

2 years ago[clangd] Find definition of ClassTemplate without going through index.
Adam Czachorowski [Tue, 2 Nov 2021 16:40:30 +0000 (17:40 +0100)]
[clangd] Find definition of ClassTemplate without going through index.

I noticed that, while go-to-def works on cases like:

namespace ns {
  template<typename T> struct Foo {};
}
using ::ns::Fo^o;

it only works because of the FileIndex. We can get definition location
directly from AST too.

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

2 years ago[flang][flang-omp-report] Remove the loop workarounds for nowait clause
Josh Mottley [Wed, 20 Oct 2021 12:20:25 +0000 (12:20 +0000)]
[flang][flang-omp-report] Remove the loop workarounds for nowait clause

In a "Worksharing-loop construct", one can add a nowait clause at the end
of the loop (i.e. at the loop tail). This clause wasn't associated with
the corresponding loop when originally worked on in flang-omp-report.
Note that this refers to parsing and parse-tree generation. To work
around it, it was needed to track such clauses and the loops.
This should no longer be required (and in fact no longer works) and so
was removed. This results in 'curLoopLogRecord' and 'loopLogRecordStack' and
all references to them being removed. This also allows for
'constructClauses' to be swapped from std::deque to llvm::SmallVector.
Lastly a new test has been added testing the "nowait" clauses in a
variety of ways.

Reviewed By: awarzynski, kiranchandramohan

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

2 years ago[lldb][NFC] Remove a bunch of unnecessary nullptr checks
Raphael Isemann [Thu, 4 Nov 2021 13:49:58 +0000 (14:49 +0100)]
[lldb][NFC] Remove a bunch of unnecessary nullptr checks

Those nullptr checks are after we already accessed the pointer.

Reviewed By: labath

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

2 years ago[OpenCL] Fix parsing of opencl-c.h as CL 3.0 with device-scope atomics enabled
Kevin Petit [Thu, 19 Aug 2021 17:28:58 +0000 (18:28 +0100)]
[OpenCL] Fix parsing of opencl-c.h as CL 3.0 with device-scope atomics enabled

https://reviews.llvm.org/D108392

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2 years ago[FuncSpec] Enable it only with -O3
Sjoerd Meijer [Thu, 4 Nov 2021 10:36:19 +0000 (10:36 +0000)]
[FuncSpec] Enable it only with -O3

Function specialisation was running at all optimisation levels (if enabled on
the command line, it is not on by default). That was an oversight and not
something we want to do. Function specialisation duplicates functions when it
triggers, so the backend is processing more functions/instructions resulting in
compile-time increases, which seems more appropriate with -O3 and inline with
GCC. Please note that since function specialisation is not enabled by default,
this didn't require updating any pass manager tests.

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

2 years ago[lldb][NFC] StringRef-ify the name parameter in CreateEnumerationType
Raphael Isemann [Thu, 4 Nov 2021 10:20:29 +0000 (11:20 +0100)]
[lldb][NFC] StringRef-ify the name parameter in CreateEnumerationType

Reviewed By: labath

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

2 years ago[libc][NFC] Allow memset (and bzero) to be inlined
Guillaume Chatelet [Thu, 4 Nov 2021 12:14:31 +0000 (12:14 +0000)]
[libc][NFC] Allow memset (and bzero) to be inlined

This allows shipping individual functions without also having to provide
memset or bzero at the expense of bigger functions.

Similar to D113097.

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

2 years ago[libc][NFC] Allow memcmp to be inlined
Guillaume Chatelet [Thu, 4 Nov 2021 12:13:29 +0000 (12:13 +0000)]
[libc][NFC] Allow memcmp to be inlined

Similar to D113097 although not strictly necessary for now. It helps
keeping the same structure for all memory functions.

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

2 years ago[libc][NFC] Allow memcpy to be inlined
Guillaume Chatelet [Thu, 4 Nov 2021 12:15:17 +0000 (12:15 +0000)]
[libc][NFC] Allow memcpy to be inlined

This allows shipping individual functions without also having to provide
`memcpy` at the expense of bigger functions.
Next is to use this `inlined_memcpy` in:
 - loader/linux/x86_64/start.cpp
 - src/string/memmove.cpp
 - src/string/mempcpy.cpp
 - src/string/strcpy.cpp
 - src/string/strdup.cpp
 - src/string/strndup.cpp

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

2 years ago[flang][flang-omp-report] Removed unnecessary comments in flang-omp-report plugin...
Josh Mottley [Fri, 29 Oct 2021 13:45:28 +0000 (13:45 +0000)]
[flang][flang-omp-report] Removed unnecessary comments in flang-omp-report plugin tests

This patch removes unnecessary comments in the flang-omp-report
plugin tests which can be implied from the file name and run command.

Reviewed By: awarzynski

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

2 years ago[PowerPC][NFC] make option ppc-formprep-max-vars can be set more than one time.
Chen Zheng [Thu, 4 Nov 2021 13:32:31 +0000 (13:32 +0000)]
[PowerPC][NFC] make option ppc-formprep-max-vars can be set more than one time.

2 years agoNo longer crash when a consteval function returns a structure
Aaron Ballman [Thu, 4 Nov 2021 13:40:22 +0000 (09:40 -0400)]
No longer crash when a consteval function returns a structure

Ensure that the destination slot exists in this case. This addresses PR51484.

2 years ago[InstCombine] Add reference to PR52397 to help with triage
Simon Pilgrim [Thu, 4 Nov 2021 13:00:42 +0000 (13:00 +0000)]
[InstCombine] Add reference to PR52397 to help with triage

rG1e5f814302f8 added the test case, I've added PR52397 to the comment to help keep track of the source of the bug

2 years ago[X86][SSE] Improve PMADDWD SimplifyDemandedVectorElts handling
Simon Pilgrim [Thu, 4 Nov 2021 12:11:42 +0000 (12:11 +0000)]
[X86][SSE] Improve PMADDWD SimplifyDemandedVectorElts handling

Check both operands for zero elements to remove unnecessary demanded elts.

Try to help reduce some minor regressions noticed in D110995

2 years ago[LLDB] Fix Cpsr size for WoA64 target
Muhammad Omair Javaid [Thu, 4 Nov 2021 12:38:24 +0000 (17:38 +0500)]
[LLDB] Fix Cpsr size for WoA64 target

CPSR on Arm64 is 4 bytes in size but windows on Arm implementation is trying to read/write 8 bytes against a byte register causing LLDB unit tests failures.

Ref: https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-arm64_nt_context

Reviewed By: mstorsjo

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

2 years ago[LIT] Add win32 PLATFORM env var to test config
Muhammad Omair Javaid [Thu, 4 Nov 2021 12:37:42 +0000 (17:37 +0500)]
[LIT] Add win32 PLATFORM env var to test config

LIT skips various system environment variables while building test
config. It turns out that we require PLATFORM environment variable for
detection of x86 vs Arm windows platform.

This patch adds system environment variable PLATFORM into LIT test
config for detection of win32 Arm platform.

Reviewed By: mstorsjo

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

2 years ago[LV] Clarify uniform worklist contains instrs demanding lane 0.
Florian Hahn [Thu, 4 Nov 2021 12:11:17 +0000 (13:11 +0100)]
[LV] Clarify uniform worklist contains instrs demanding lane 0.

2 years ago[llvm-objdump] Fix the Assertion failure when providing invalid --debug-vars or ...
gbreynoo [Thu, 4 Nov 2021 11:01:32 +0000 (11:01 +0000)]
[llvm-objdump] Fix the Assertion failure when providing invalid --debug-vars or --dwarf values

As seen in https://bugs.llvm.org/show_bug.cgi?id=52213 llvm-objdump
asserts if either the --debug-vars or the --dwarf options are provided
with invalid values. As suggested, this fix adds use of a default value
to these options and errors when given bad input.

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

2 years agoCoroutines: don't infer function attrs before lowering
Tim Northover [Fri, 22 Oct 2021 08:13:02 +0000 (09:13 +0100)]
Coroutines: don't infer function attrs before lowering

Coroutines have weird semantics that don't quite match normal LLVM functions,
so trying to infer even simple attributes based on thier contents can go wrong.

2 years ago[mlir] Fix typos in comments
Markus Böck [Thu, 4 Nov 2021 09:59:35 +0000 (10:59 +0100)]
[mlir] Fix typos in comments

2 years ago[fir] Add fir.insert_on_range conversion
Valentin Clement [Thu, 4 Nov 2021 09:36:00 +0000 (10:36 +0100)]
[fir] Add fir.insert_on_range conversion

Convert fir.insert_on_range operation to corresponding
llvm.insertvalue operations.

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

Reviewed By: mehdi_amini

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

2 years ago[InstCombine] Fix infinite recursion in ashr/xor vector fold.
David Green [Thu, 4 Nov 2021 09:24:27 +0000 (09:24 +0000)]
[InstCombine] Fix infinite recursion in ashr/xor vector fold.

The added test has poison lanes due to the vector shuffle. This can
cause an infinite loop of combines in instcombine where it folds
xor(ashr, -1) -> select (icmp slt 0), -1, 0 -> sext (icmp slt 0) -> xor(ashr, -1).
We usually prevent this by checking that the xor constant is not -1,
but with vectors some of the lanes may be -1, some may be poison. So
this changes the way we detect that from "!C1->isAllOnesValue()" to
"!match(C1, m_AllOnes())", which is more able to detect that some of the
lanes are poison.

Fixes PR52397

2 years ago[libcxx] Remove nonstandard _FilesystemClock::{to,from}_time_t
Martin Storsjö [Tue, 2 Nov 2021 16:32:09 +0000 (16:32 +0000)]
[libcxx] Remove nonstandard _FilesystemClock::{to,from}_time_t

These are not standard methods, neither libstdc++ nor MSVC STL provide
them.

In practice, one of them was untested and the other one was only used in
one single test.

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

2 years ago[lldb] Fix TestEchoCommands.test again
Lawrence D'Anna [Thu, 4 Nov 2021 07:58:31 +0000 (00:58 -0700)]
[lldb] Fix TestEchoCommands.test again

In 7f01f78593d6 [lldb] update TestEchoCommands -- I fixed this test,
but not on windows, becuase I used  some unix shell syntax that
doesn't work with cmd.exe.   Fixed it so it will work in both.
Test logic is the same.

This is a trivial fix, so bypassing review to get the build clean again
ASAP.

2 years ago[fir] Restrict array type on fir.insert_on_range
Valentin Clement [Thu, 4 Nov 2021 07:53:49 +0000 (08:53 +0100)]
[fir] Restrict array type on fir.insert_on_range

Sequence type had no restriction on the insert_on_range operation.
This patch adds a restriction for the type to have constant shape
and size.

Reviewed By: mehdi_amini

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

2 years agoFix -Wformat warnings reported by GCC.
Martin Liska [Wed, 3 Nov 2021 12:49:21 +0000 (13:49 +0100)]
Fix -Wformat warnings reported by GCC.

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