platform/upstream/llvm.git
2 years agoSpecify Clang vector builtins.
Florian Hahn [Mon, 25 Oct 2021 08:55:21 +0000 (09:55 +0100)]
Specify Clang vector builtins.

This patch specifies a set of vector builtins for Clang, as discussed on
cfe-dev:
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068999.html
https://lists.llvm.org/pipermail/cfe-dev/2021-October/069070.html

Reviewed By: scanon

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

2 years ago[libc++] Include nasty_macros.h when running tests with from-scratch configs
Louis Dionne [Mon, 25 Oct 2021 14:59:59 +0000 (10:59 -0400)]
[libc++] Include nasty_macros.h when running tests with from-scratch configs

This was forgotten when setting up the from-scratch configs.

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

2 years agotsan: turn off COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED
Dmitry Vyukov [Mon, 25 Oct 2021 12:58:43 +0000 (14:58 +0200)]
tsan: turn off COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED

All tsan interceptors check for initialization and/or initialize things
as necessary lazily, so we can pretend everything is initialized in the
COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED check to avoid double-checking
for initialization (this is only necessary for sanitizers that don't
handle initialization on common grounds).

Reviewed By: melver

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

2 years agosanitizer_common: fix deadlock detector output
Dmitry Vyukov [Tue, 26 Oct 2021 13:01:09 +0000 (15:01 +0200)]
sanitizer_common: fix deadlock detector output

Print PC of the previous lock, not the current one.
The current one will be printed during unwind.

Reviewed By: melver

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

2 years ago[clangd] IncludeCleaner: don't stop the traversal
Kirill Bobyrev [Tue, 26 Oct 2021 14:08:54 +0000 (16:08 +0200)]
[clangd] IncludeCleaner: don't stop the traversal

I was under the impression that `return false;` in the
RecursiveASTVisitor stops the traversal for the subtree but it appears
that it stops the whole tree traversal, so this change introduces a bug
where `ReferencedLocationCrawler` will not collect any symbols past an
enum.

This is a follow-up on D112209.

2 years ago[AMDGPU] Remove unused CSR defs
Neubauer, Sebastian [Tue, 26 Oct 2021 13:45:10 +0000 (15:45 +0200)]
[AMDGPU] Remove unused CSR defs

CSR_AMDGPU_VGPRs_24_255 and CSR_AMDGPU_VGPRs_32_255 are not used
anywhere, so remove them.

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

2 years ago[openmp][lit] Add support to OpenMP lit.cfg for ROCR_VISIBLE_DEVICES env-var
Ron Lieberman [Tue, 26 Oct 2021 01:53:15 +0000 (01:53 +0000)]
[openmp][lit] Add support to OpenMP lit.cfg for ROCR_VISIBLE_DEVICES env-var

add support for ROCR_VISIBLE_DEVICES similar to name and purpose
as CUDA_VISIBLE_DEVICES

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

2 years ago[clang] Implement CFG construction for @try and @catch
Nico Weber [Thu, 21 Oct 2021 10:53:12 +0000 (06:53 -0400)]
[clang] Implement CFG construction for @try and @catch

@finally is still not implemented.

With this, clang can emit -Wreturn-type warnings for functions containing
@try/@catch (but not yet @finally), and -Wunreachable-code also works for those
functions.

The implementation is similar to D36914.

Part of PR46693.

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

2 years ago[clang] Make loop in CFGBuilder::VisitCXXTryStmt() more canonical
Nico Weber [Tue, 26 Oct 2021 13:35:20 +0000 (09:35 -0400)]
[clang] Make loop in CFGBuilder::VisitCXXTryStmt() more canonical

No behavior change.

2 years ago[clang] Simplify CFG block printing code a bit
Nico Weber [Tue, 26 Oct 2021 13:29:41 +0000 (09:29 -0400)]
[clang] Simplify CFG block printing code a bit

No behavior change.

2 years ago[clang] Use consistent punctuation at end of Block NULL comment
Nico Weber [Tue, 26 Oct 2021 13:23:16 +0000 (09:23 -0400)]
[clang] Use consistent punctuation at end of Block NULL comment

No behavior change.

2 years ago[AMDGPU] Add constrained shift pattern matches.
Abinav Puthan Purayil [Wed, 22 Sep 2021 10:32:52 +0000 (16:02 +0530)]
[AMDGPU] Add constrained shift pattern matches.

The motivation for this is due to clang's conformance to
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#operators-shift
which makes clang emit (<shift> a, (and b, <width> - 1)) for `a <shift> b`
in OpenCL where a is an int of bit width <width>.

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

2 years ago[libunwind] Take 2: Use the from-scratch testing configuration by default
Louis Dionne [Tue, 12 Oct 2021 18:10:02 +0000 (14:10 -0400)]
[libunwind] Take 2: Use the from-scratch testing configuration by default

Summary:
This commit switches libunwind from using the complicated logic in
libc++'s testing configuration to a from-scratch configuration.
I tried to make sure that all cases that were handled in the old
config were handled by this one too, so hopefully this shouldn't
break anyone. However, if you encounter issues with this change,
please let me know and feel free to revert if I don't reply quickly.

This change was engineered to be easily revertable.

This commit is a re-application of 5a8ad80b6fa5, which was reverted in
070a2ddcb665 because it broke the Bootstrapping build. This has now been
addressed by tweaking the from-scratch config.

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

2 years ago[PowerPC] use right extend type for SCEV
Chen Zheng [Tue, 26 Oct 2021 01:33:27 +0000 (01:33 +0000)]
[PowerPC] use right extend type for SCEV

Fix an issue caused by D108750

Reviewed By: nemanjai

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

2 years ago[AMDGPU] Enable 48-bit mul in AMDGPUCodeGenPrepare.
Abinav Puthan Purayil [Sat, 23 Oct 2021 15:35:32 +0000 (21:05 +0530)]
[AMDGPU] Enable 48-bit mul in AMDGPUCodeGenPrepare.

We were bailing out of creating 24-bit muls for results wider than 32
bits in AMDGPUCodeGenPrepare. With the 24-bit mulhi intrinsic, this
change teaches AMDGPUCodeGenPrepare to generate the 48-bit mul
correctly.

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

2 years ago[AMDGPU] Implement llvm.amdgcn.mulhi.[i,u]24 intrinsics.
Abinav Puthan Purayil [Sat, 23 Oct 2021 07:15:32 +0000 (12:45 +0530)]
[AMDGPU] Implement llvm.amdgcn.mulhi.[i,u]24 intrinsics.

These intrinsics maps to the 24-bit v_mul_hi instructions.

This change also fixes an incorrect assumption on the associativity of
24-bit mulhi in its SDNode record in tblgen.

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

2 years ago[fir][NFC] Fix indentation for fir.alloca builders
Valentin Clement [Tue, 26 Oct 2021 12:55:47 +0000 (14:55 +0200)]
[fir][NFC] Fix indentation for fir.alloca builders

2 years ago[x86] use cast instead of dyn_cast for unchecked usage; NFC
Sanjay Patel [Tue, 26 Oct 2021 12:10:34 +0000 (08:10 -0400)]
[x86] use cast instead of dyn_cast for unchecked usage; NFC

This was noted as an independent clean-up in D112464.

2 years ago[x86] add test for vector increment; NFC
Sanjay Patel [Mon, 25 Oct 2021 19:45:08 +0000 (15:45 -0400)]
[x86] add test for vector increment; NFC

2 years ago[clangd] Remove tricky integration test that flakes/fails on some platforms.
Sam McCall [Tue, 26 Oct 2021 12:19:05 +0000 (14:19 +0200)]
[clangd] Remove tricky integration test that flakes/fails on some platforms.

This functionality is covered by unittests, will add a better
integration test soon.

2 years ago[lldb] [Host] Move port predicate-related logic to gdb-remote
Michał Górny [Sat, 23 Oct 2021 09:15:00 +0000 (11:15 +0200)]
[lldb] [Host] Move port predicate-related logic to gdb-remote

Remove the port predicate from Socket and ConnectionFileDescriptor,
and move it to gdb-remote.  It is specifically relevant to the threading
used inside gdb-remote and with the new port callback API, we can
reliably move it there.  While at it, switch from the custom Predicate
to std::promise/std::future.

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

2 years ago[AMDGPU] Fix setcc combine for i128
Neubauer, Sebastian [Mon, 25 Oct 2021 08:58:01 +0000 (10:58 +0200)]
[AMDGPU] Fix setcc combine for i128

The combine asserted if constants could not be represented as uint64_t.
Use APInts to fix this.

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

2 years ago[AMDGPU] Use standard MachineBasicBlock::getFallThrough method. NFCI.
Jay Foad [Tue, 4 May 2021 10:14:42 +0000 (11:14 +0100)]
[AMDGPU] Use standard MachineBasicBlock::getFallThrough method. NFCI.

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

2 years ago[lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor
Michał Górny [Fri, 22 Oct 2021 15:42:23 +0000 (17:42 +0200)]
[lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

Unify the listen and connect code inside lldb-server to use
ConnectionFileDescriptor uniformly rather than a mix of it and Acceptor.
This involves:

- adding a function to map legacy values of host:port parameter
  (including legacy server URLs) into CFD-style URLs

- adding a callback to return "local socket id" (i.e. UNIX socket path
  or TCP port number) between listen() and accept() calls in CFD

- adding a "unix-abstract-accept" scheme to CFD

As an additional advantage, this permits lldb-server to accept any URL
known to CFD including the new serial:// scheme.  Effectively,
lldb-server can now listen on the serial port.  Tests for connecting
over a pty are added to test that.

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

2 years ago[lldb] Fix PlatformAppleSimulator for a458ef4f
Pavel Labath [Tue, 26 Oct 2021 11:03:09 +0000 (13:03 +0200)]
[lldb] Fix PlatformAppleSimulator for a458ef4f

2 years ago[clangd] Add a way to enable IncludeCleaner through config
Kirill Bobyrev [Tue, 26 Oct 2021 09:53:34 +0000 (11:53 +0200)]
[clangd] Add a way to enable IncludeCleaner through config

This is useful for dogfooding the feature and spotting bugs.

Reviewed By: sammccall

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

2 years ago[MLIR] Fix AffineExpr getLargestKnownDivisor for ceildiv and floordiv
Uday Bondhugula [Mon, 11 Oct 2021 10:18:06 +0000 (15:48 +0530)]
[MLIR] Fix AffineExpr getLargestKnownDivisor for ceildiv and floordiv

Fix AffineExpr `getLargestKnownDivisor` for ceil/floor div cases.
In these cases, nothing can be inferred on the divisor of the
result.

Add test case for `mod` as well.

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

2 years ago[lldb] [Communication] Add a WriteAll() method that resumes writing
Michał Górny [Wed, 20 Oct 2021 19:28:25 +0000 (21:28 +0200)]
[lldb] [Communication] Add a WriteAll() method that resumes writing

Add a Communication::WriteAll() that resumes Write() if the initial call
did not write all data.  Use it in GDBRemoteCommunication when sending
packets in order to fix handling partial writes (i.e. just resume/retry
them rather than erring out).  This fixes LLDB failures when writing
large packets to a pty.

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

2 years ago[SystemZ] Provide size values for PATCHPOINT, STACKMAP and FENTRY_CALL.
Jonas Paulsson [Mon, 25 Oct 2021 14:02:20 +0000 (16:02 +0200)]
[SystemZ] Provide size values for PATCHPOINT, STACKMAP and FENTRY_CALL.

All instructions must have a correct size value close to emission when
SystemZLongBranch runs, or a necessary branch relaxation may be missed.

This patch also adds an assert for instruction sizes in SystemZLongBranch.

Review: Ulrich Weigand

2 years ago[LangRef] Document that DataLayout defaults to little-endian
Fraser Cormack [Fri, 22 Oct 2021 14:19:25 +0000 (15:19 +0100)]
[LangRef] Document that DataLayout defaults to little-endian

Little-endian has apparently been the default since 2014.

Reviewed By: nikic

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

2 years ago[AArch64] Add a costmodel test for overflowing arithmatic. NFC
David Green [Tue, 26 Oct 2021 09:35:12 +0000 (10:35 +0100)]
[AArch64] Add a costmodel test for overflowing arithmatic. NFC

2 years agoModernize and simplify HostInfo::GetOSKernelDescription
Pavel Labath [Mon, 25 Oct 2021 14:44:12 +0000 (16:44 +0200)]
Modernize and simplify HostInfo::GetOSKernelDescription

Replace bool+by-ref argument with llvm::Optional, and move the common
implementation into HostInfoPOSIX. Based on my (simple) experiment,
the uname and the sysctl approach return the same value on MacOS, so
there's no need for a mac-specific implementation of this functionality.

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

2 years ago[SCEV] Use reverse() (NFC)
Nikita Popov [Tue, 26 Oct 2021 09:08:58 +0000 (11:08 +0200)]
[SCEV] Use reverse() (NFC)

2 years ago[clangd] IncludeCleaner: Don't consider the definition as usage for function forward...
Kirill Bobyrev [Tue, 26 Oct 2021 08:37:05 +0000 (10:37 +0200)]
[clangd] IncludeCleaner: Don't consider the definition as usage for function forward declarations

Reviewed By: kadircet

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

2 years ago[fir] Add substring to fir.slice operation
Valentin Clement [Tue, 26 Oct 2021 08:32:48 +0000 (10:32 +0200)]
[fir] Add substring to fir.slice operation

This patch adds the substriing information to the fir.slice
operation. This will be used by character operations in later
upstreaming patches.

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

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[lldb] Remove ConstString from Platform plugin names
Pavel Labath [Thu, 21 Oct 2021 19:00:33 +0000 (21:00 +0200)]
[lldb] Remove ConstString from Platform plugin names

2 years ago[lldb/DWARF] Move a declaration closer to its use
Pavel Labath [Tue, 26 Oct 2021 07:58:10 +0000 (09:58 +0200)]
[lldb/DWARF] Move a declaration closer to its use

Adresses post-commit feedback on D112310.

2 years agoMake Python MLIR Operation not iterable
Mehdi Amini [Wed, 20 Oct 2021 19:51:52 +0000 (19:51 +0000)]
Make Python MLIR Operation not iterable

The current behavior is conveniently allowing to iterate on the regions of an operation
implicitly by exposing an operation as Iterable. However this is also error prone and
code that may intend to iterate on the results or the operands could end up "working"
apparently instead of throwing a runtime error.
The lack of static type checking in Python contributes to the ambiguity here, it seems
safer to not do this and require and explicit qualification to iterate (`op.results`, `op.regions`, ...).

Reviewed By: ftynse

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

2 years ago[LLDB] Fix LLDB buildbots break due to --image-base
Muhammad Omair Javaid [Tue, 26 Oct 2021 07:07:11 +0000 (12:07 +0500)]
[LLDB] Fix LLDB buildbots break due to --image-base

LLDB build were failing due to following two test failures:
lldb-shell :: ObjectFile/ELF/basic-info.yaml
lldb-shell :: SymbolFile/DWARF/x86/debug-types-address-ranges.s

There were caused by commit 6506907a0a1a8a789ad7036ef911f7e31213c9a5

2 years ago[llvm-profgen] Allow unsymbolized profile as perf input
wlei [Fri, 15 Oct 2021 03:18:53 +0000 (20:18 -0700)]
[llvm-profgen] Allow unsymbolized profile as perf input

This change allows the unsymbolized profile as input. The unsymbolized profile is created by `llvm-profgen` with `--skip-symbolization` and it's after the sample aggregation but before symbolization , so it has much small file size. It can be used for sample merging and trimming,  also is useful for debugging or adding test cases. A switch `--unsymbolized-profile=file-patch` is added for this.

Format of unsymbolized profile:
```

   [context stack1]    # If it's a CS profile
      number of entries in RangeCounter
      from_1-to_1:count_1
      from_2-to_2:count_2
      ......
      from_n-to_n:count_n
      number of entries in BranchCounter
      src_1->dst_1:count_1
      src_2->dst_2:count_2
      ......
      src_n->dst_n:count_n
    [context stack2]
      ......
```

Reviewed By: hoy, wenlei

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

2 years ago[NFC] Remove obsolete simplifyOnceImpl function
Max Kazantsev [Tue, 26 Oct 2021 06:38:03 +0000 (13:38 +0700)]
[NFC] Remove obsolete simplifyOnceImpl function

The function simplifyOnce only calls simplifyOnceImpl and does nothing else.
Having this separate helper makes no sense. Removing it.

Patch by Dmitry Bakunevich!

Differential Revision: https://reviews.llvm.org/D112517
Reviewed By: mkazantsev

2 years agollvm pretty printers: Fix StringRef and workaround StringMap in Python 2
David Blaikie [Tue, 26 Oct 2021 06:48:09 +0000 (23:48 -0700)]
llvm pretty printers: Fix StringRef and workaround StringMap in Python 2

2 years ago[NFC] [LoopPeel] Update IDoms of non-loop blocks dominated by the loop
Max Kazantsev [Tue, 26 Oct 2021 06:09:07 +0000 (13:09 +0700)]
[NFC] [LoopPeel] Update IDoms of non-loop blocks dominated by the loop

When peeling a loop, we assume that the latch has a `br` terminator and that
all loop exits are either terminated with an `unreachable` or have a terminating
deoptimize call. So when we peel off the 1st iteration, we change the IDom of
all loop exits to the peeled copy of `NCD(IDom(Exit), Latch)`. This works now,
but if we add logic to support loops with exits that are followed by a block
with an `unreachable` or a terminating deoptimize call, changing the exit's idom
wouldn't be enough and DT would be broken.

For example, let `Exit1` and `Exit2` are loop exits, and each of them
unconditionally branches to the same `unreachable` terminated block. So neither
of the exits dominates this unreachable block. If we change the IDoms of the
exits to some peeled loop block, we don't update the dominators of the unreachable
block. Currently we just don't get to the peeling logic, saying that we can't peel
such loops.

Previously we stored exits' IDoms in a map before peeling a loop and then, after
peeling off one iteration, we changed their IDoms.
Now we use the same logic not only for exits but for all non-loop blocks dominated
by the loop.
So when we add logic to support peeling loops with exits which branch, for example,
to an unreachable-terminated block, we would update the IDoms not only for exits,
but for their successors.

Patch by Dmitry Makogon!

Differential Revision: https://reviews.llvm.org/D111611
Reviewed By: mkazantsev, nikic

2 years ago[clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in...
Carlos Galvez [Fri, 22 Oct 2021 17:38:34 +0000 (17:38 +0000)]
[clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in variables

clang-tidy can be used to statically analyze CUDA code,
thanks to clang being able to compile CUDA code natively.
This makes clang-tidy the one and only open-source
static analyzer for CUDA.

However it currently warns for native CUDA built-in
variables, like threadIdx, due to the way they
are implemented in clang.

Users don't need to know the details of the clang
implementation, and they should continue to write
idiomatic code. Therefore, suppress the warning
if a CUDA built-in variable is encountered.

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

2 years ago[X86] Move splat addends from the gather/scatter index operand to the base address
Phoebe Wang [Tue, 26 Oct 2021 03:56:15 +0000 (11:56 +0800)]
[X86] Move splat addends from the gather/scatter index operand to the base address

This can avoid a vector add and a constant pool load. Or an explicit broadcast in case of non-constant.

Also reverse the transform any time we encounter a constant index addend that can't be moved to base. In that case pull the constant from base into the index. This reduces code size needed for the displacement since we needed the index add anyway. Limit this to scale of 1 to avoid divisibility and wrap issues.

Authored by Craig.

Reviewed By: craig.topper

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

2 years ago[mlir-c] Avoid compiler warning
Jacques Pienaar [Tue, 26 Oct 2021 04:11:50 +0000 (21:11 -0700)]
[mlir-c] Avoid compiler warning

Setting visibility & static leads to warning about attribute being
ignored.

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

2 years ago[TableGen] Fix codgen of InstrMapping with multiple columns and values
Jyun-Yan You [Tue, 26 Oct 2021 04:00:23 +0000 (21:00 -0700)]
[TableGen] Fix codgen of InstrMapping with multiple columns and values

This patch fixes invalid syntax of generated code for InstrMapping
that has multiple columns and values.

Reviewed By: craig.topper

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

2 years ago[lldb] Skip tests for target var without a proc on both arm64 & arm64e
Jonas Devlieghere [Tue, 26 Oct 2021 03:44:59 +0000 (20:44 -0700)]
[lldb] Skip tests for target var without a proc on both arm64 & arm64e

LLDB needs to be taught about chained fixups.

<rdar://problem/37773624>

2 years ago[AIX][ZOS] Disable tests due to lack of Objective-C support
Jake Egan [Tue, 26 Oct 2021 03:32:02 +0000 (23:32 -0400)]
[AIX][ZOS] Disable tests due to lack of Objective-C support

AIX and z/OS lack Objective-C support, so mark these tests as unsupported for AIX and z/OS.

This patch follows the same reasoning as D109060.

Reviewed By: jsji

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

2 years ago[clangd] Attempt to fix buildbots
Shoaib Meenai [Tue, 26 Oct 2021 03:16:59 +0000 (20:16 -0700)]
[clangd] Attempt to fix buildbots

http://45.33.8.238/win/47615/step_4.txt is a sample error; I believe it
just needs the right header to be included.

2 years ago[lld-macho] Make test produce the dead.o and live.o that are used below.
Vy Nguyen [Tue, 26 Oct 2021 02:10:24 +0000 (22:10 -0400)]
[lld-macho] Make test produce the dead.o and live.o that are used below.
Follow up fix to breakages in D112485

2 years ago[lld-macho] Fix incremental build (again) from D112485
Vy Nguyen [Tue, 26 Oct 2021 01:51:34 +0000 (21:51 -0400)]
[lld-macho] Fix incremental build (again) from D112485

2 years ago[lld-macho] Fix incremental builds
Jez Ng [Tue, 26 Oct 2021 00:50:35 +0000 (20:50 -0400)]
[lld-macho] Fix incremental builds

2 years ago[ELF] Simplify sortSection. NFC
Fangrui Song [Mon, 25 Oct 2021 23:57:46 +0000 (16:57 -0700)]
[ELF] Simplify sortSection. NFC

2 years ago[lldb] Configure CMake policy CMP0116 for standalone builds
Dave Lee [Mon, 25 Oct 2021 22:49:46 +0000 (15:49 -0700)]
[lldb] Configure CMake policy CMP0116 for standalone builds

Using CMake >=3.20 results in many warnings about this new policy. This change silences the warnings by explicitly declaring use of the "OLD" behavior.

This applies D101083 to LLDBStandalone.cmake.

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

2 years ago[clangd] Flush stderr after signal handlers run, so we always get the full stack...
Sam McCall [Mon, 25 Oct 2021 23:08:28 +0000 (01:08 +0200)]
[clangd] Flush stderr after signal handlers run, so we always get the full stack/crash info

2 years ago[lld-macho][nfc] Test that we don't emit undef symbol errors for dead code
Jez Ng [Mon, 25 Oct 2021 20:21:08 +0000 (16:21 -0400)]
[lld-macho][nfc] Test that we don't emit undef symbol errors for dead code

This is what ld64 does too, so we have parity here (though I think ld64
still removes dead code more effectively than we do...)

Reviewed By: #lld-macho, thakis

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

2 years agoBitcode: Use Expected<T>::takeError() and moveInto() more, NFC
Duncan P. N. Exon Smith [Mon, 25 Oct 2021 20:56:43 +0000 (13:56 -0700)]
Bitcode: Use Expected<T>::takeError() and moveInto() more, NFC

Avoid naming some Expected<T> values in the Bitcode reader by using
takeError() and moveInto() more often. This follows the smaller set of
changes included in 2410fb4616b2c08bbaddd44e6c11da8285fbd1d3.

2 years ago[gn build] Port 045695f85cb8
LLVM GN Syncbot [Mon, 25 Oct 2021 22:58:46 +0000 (22:58 +0000)]
[gn build] Port 045695f85cb8

2 years ago[clangd] Print current request context along with the stack trace
Emma Blink [Mon, 25 Oct 2021 15:18:48 +0000 (17:18 +0200)]
[clangd] Print current request context along with the stack trace

Motivation:

At the moment it is hard to attribute a clangd crash to a specific request out of all in-flight requests that might be processed concurrently. So before we can act on production clangd crashes, we have to do quite some digging through the log tables populated by our in-house VSCode extension or sometimes even directly reach out to the affected developer. Having all the details needed to reproduce a crash printed alongside its stack trace has a potential to save us quite some time, that could better be spent on fixing the actual problems.

Implementation approach:

* introduce `ThreadCrashReporter` class that allows to set a temporary signal handler for the current thread
* follow RAII pattern to simplify printing context for crashes occurring within a particular scope
* hold `std::function` as a handler to allow capturing context to print
* set local `ThreadCrashReporter` within `JSONTransport::loop()` to print request JSON for main thread crashes, and in `ASTWorker::run()` to print the file paths, arguments and contents for worker thread crashes

`ThreadCrashReporter` currently allows only one active handler per thread, but the approach can be extended to support stacked handlers printing context incrementally.

Example output for main thread crashes:

  ```
  ...
  #15 0x00007f7ddc819493 __libc_start_main (/lib64/libc.so.6+0x23493)
  #16 0x000000000249775e _start (/home/emmablink/local/llvm-project/build/bin/clangd+0x249775e)
  Signalled while processing message:
  {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "file:///home/emmablink/test.cpp", "languageId": "cpp", "version": 1, "text": "template <typename>\nclass Bar {\n  Bar<int> *variables_to_modify;\n  foo() {\n    for (auto *c : *variables_to_modify)\n      delete c;\n  }\n};\n"}}}
  ```

Example output for AST worker crashes:

  ```
  ...
  #41 0x00007fb18304c14a start_thread pthread_create.c:0:0
  #42 0x00007fb181bfcdc3 clone (/lib64/libc.so.6+0xfcdc3)
  Signalled during AST action:
  Filename: test.cpp
  Directory: /home/emmablink
  Command Line: /usr/bin/clang -resource-dir=/data/users/emmablink/llvm-project/build/lib/clang/14.0.0 -- /home/emmablink/test.cpp
  Version: 1
  Contents:
  template <typename>
  class Bar {
    Bar<int> *variables_to_modify;
    foo() {
      for (auto *c : *variables_to_modify)
        delete c;
    }
  };
  ```

Testing:

The unit test covers the thread-localitity and nesting aspects of `ThreadCrashReporter`. There might be way to set up a lit-based integration test that would spawn clangd, send a message to it, signal it immediately and check the standard output, but this might be prone to raceconditions.

Reviewed By: sammccall

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

2 years ago[ELF] Change SharedFile::soName from std::string to StringRef
Fangrui Song [Mon, 25 Oct 2021 22:54:04 +0000 (15:54 -0700)]
[ELF] Change SharedFile::soName from std::string to StringRef

2 years agoWhen generating C++ code, use C++ string escaping.
Matthias Kramm [Mon, 25 Oct 2021 22:53:08 +0000 (22:53 +0000)]
When generating C++ code, use C++ string escaping.

Reviewed By: Mogball

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

2 years ago[clang][Fuchsia] Add additional unit test for availability attr
Haowei Wu [Thu, 21 Oct 2021 20:56:09 +0000 (13:56 -0700)]
[clang][Fuchsia] Add additional unit test for availability attr

This change adds additional unit tests for availability attribute
support for Fuchsia platform.

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

2 years ago[PPC][LLVM] Inclusive terms: remove references to sanity check in lib/Target/PowerPC
Zarko Todorovski [Mon, 25 Oct 2021 20:18:26 +0000 (16:18 -0400)]
[PPC][LLVM] Inclusive terms: remove references to sanity check in lib/Target/PowerPC

Removed references to `sanity check` in `PPCBranchCoalescing.cpp` code comments.
No word substitution made in this case, as the comments and code following illustrated are
sufficient IMO.

Reviewed By: quinnp

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

2 years ago[bazel build] (manually) port da47ec3ca076
Alina Sbirlea [Mon, 25 Oct 2021 22:07:32 +0000 (15:07 -0700)]
[bazel build] (manually) port da47ec3ca076

2 years ago[ELF] Remove irrelevant group signature hack working around old gold -r
Fangrui Song [Mon, 25 Oct 2021 22:09:08 +0000 (15:09 -0700)]
[ELF] Remove irrelevant group signature hack working around old gold -r

2 years ago[libc] fix strtol returning the wrong length
Michael Jones [Wed, 20 Oct 2021 20:08:46 +0000 (13:08 -0700)]
[libc] fix strtol returning the wrong length

Previously, strtol/ll/ul/ull would return a pointer to the end of its
parsing, regardless of if it detected a number. Now it will return a
length of 0 when it doesn't find a number.

Reviewed By: sivachandra

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

2 years ago[libomptarget][NFC] Add comment explaining why we pass argument bases and
Georgios Rokos [Mon, 25 Oct 2021 21:48:53 +0000 (14:48 -0700)]
[libomptarget][NFC] Add comment explaining why we pass argument bases and
offsets as two separate entities to the plugins.

2 years ago[gn build] (manually) port da47ec3ca076
Nico Weber [Mon, 25 Oct 2021 21:48:35 +0000 (17:48 -0400)]
[gn build] (manually) port da47ec3ca076

2 years ago[Sanitizer] Strip PAC from PC in StackTrace::GetNextInstructionPc()
Julian Lettner [Mon, 25 Oct 2021 19:49:41 +0000 (12:49 -0700)]
[Sanitizer] Strip PAC from PC in StackTrace::GetNextInstructionPc()

In TSan, we use the a function reference (`__tsan_stack_initialization`)
in a call to `StackTrace::GetNextInstructionPc(uptr pc)`.  We sign
function pointers, so we need to strip the signature from this function
pointer.

Caused by: https://reviews.llvm.org/D111147

Radar-Id: rdar://problem/83940546

2 years ago[mlir][tosa] Correct tosa.avg_pool2d for specification error
Robert Suderman [Mon, 25 Oct 2021 21:30:06 +0000 (14:30 -0700)]
[mlir][tosa] Correct tosa.avg_pool2d for specification error

Specification specified the output type for quantized average pool should be
an i32. Only accumulator should be an i32, result type should match the input
type.

Caused in https://reviews.llvm.org/D111590

Reviewed By: sjarus, GMNGeoffrey

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

2 years ago[clangd] Respect diagnostic suppression during preamble build
Nathan Ridge [Mon, 25 Oct 2021 06:42:11 +0000 (02:42 -0400)]
[clangd] Respect diagnostic suppression during preamble build

Fixes https://github.com/clangd/clangd/issues/906

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

2 years ago[ELF] Remove irrelevant SHT_INIT_ARRAY/SHT_FINI_ARRAY hack
Fangrui Song [Mon, 25 Oct 2021 21:23:05 +0000 (14:23 -0700)]
[ELF] Remove irrelevant SHT_INIT_ARRAY/SHT_FINI_ARRAY hack

The hack is irrelevant for two reasons:

* binutils 2.24 is quite old and cannot handle R_X86_64_REX_GOTPCRELX from 2016 onwards anyway
* `canMergeToProgbits` allows combining SHT_INIT_ARRAY/SHT_FINI_ARRAY into SHT_PROGBITS

2 years ago[OpenMP][Offloading] Only get trip count if team construct
Shilei Tian [Mon, 25 Oct 2021 21:15:56 +0000 (17:15 -0400)]
[OpenMP][Offloading] Only get trip count if team construct

Reviewed By: grokos

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

2 years ago[test] Make test added in D112473 check the IR
Arthur Eubanks [Mon, 25 Oct 2021 21:04:18 +0000 (14:04 -0700)]
[test] Make test added in D112473 check the IR

The test was intended to also check the IR to be empty.

2 years ago[LegalizeTypes][TargetLowering] Merge getShiftAmountTyForConstant into TargetLowering...
Craig Topper [Mon, 25 Oct 2021 21:06:52 +0000 (14:06 -0700)]
[LegalizeTypes][TargetLowering] Merge getShiftAmountTyForConstant into TargetLowering::getShiftAmountTy.

getShiftAmountTyForConstant is a special helper that changes the
shift amount to i32 if the type chosen by
TargetLowering::getShiftAmountTy can't represent all possible values.
This is needed to satisfy an assert in SelectionDAG::getNode.

It requires additional consideration to know when this helper should be used.
I'm not sure that we are always using it when we should.

This patch merges the getShiftAmountTyForConstant handling into
TargetLowering::getShiftAmountTy so we don't need to think about it
anymore.

Technically this may slightly increase compile times since the majority
of callers of getShiftAmountTy won't need this. Hopefully, this isn't
an issue in practice.

Reviewed By: RKSimon

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

2 years ago[ELF] Update comments/diagnostics for -defsym and -image-base to use the canonical...
Fangrui Song [Mon, 25 Oct 2021 21:01:36 +0000 (14:01 -0700)]
[ELF] Update comments/diagnostics for -defsym and -image-base to use the canonical two-dash form

2 years agoBasic: Stop using expectedToOptional() in FileManagerTest, NFC
Duncan P. N. Exon Smith [Mon, 25 Oct 2021 20:37:45 +0000 (13:37 -0700)]
Basic: Stop using expectedToOptional() in FileManagerTest, NFC

Remove a couple of uses of expectedToOptional() in FileManagerTest,
using Expected<T>::moveInto() to extract the value instead instead.

2 years ago[SCEV] Move SCEVLostPoisonFlags() check into SCEVExpander
Nikita Popov [Sun, 24 Oct 2021 21:42:23 +0000 (23:42 +0200)]
[SCEV] Move SCEVLostPoisonFlags() check into SCEVExpander

Always insert values into ExprValueMap, and instead skip using them
in SCEVExpander if poison-generating flags have been lost. This
ensures that all values that are in ValueExprMap are also in
ExprValueMap, so we can use the latter to invalidate the former.

This change is probably not entirely NFC for the case where
originally the SCEV had no nowrap flags but they were inferred
later, in which case that would now allow reusing the existing
value for expansion.

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

2 years ago[AlwaysInliner] Invalidate analyses when we delete functions
Arthur Eubanks [Mon, 25 Oct 2021 17:52:30 +0000 (10:52 -0700)]
[AlwaysInliner] Invalidate analyses when we delete functions

Fixes PR52292.

Reviewed By: asbirlea

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

2 years ago[gn build] Add missing CodeGenTests dependency
Arthur Eubanks [Mon, 25 Oct 2021 20:33:28 +0000 (13:33 -0700)]
[gn build] Add missing CodeGenTests dependency

Fixes link errors.

2 years ago[libc][NFC] Remove extra space in libc/CMakeLists.txt
Joe Loser [Mon, 25 Oct 2021 20:29:14 +0000 (16:29 -0400)]
[libc][NFC] Remove extra space in libc/CMakeLists.txt

2 years ago[libc][NFC] Remove extra slash in path in libc/CMakeLists.txt
Joe Loser [Mon, 25 Oct 2021 20:26:20 +0000 (16:26 -0400)]
[libc][NFC] Remove extra slash in path in libc/CMakeLists.txt

Remove extra `/` in path to match the include filepath from the previous
line.

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

2 years ago[docs][NewPM] Add example C++ code on how to actually use the new PM
Arthur Eubanks [Mon, 25 Oct 2021 18:46:17 +0000 (11:46 -0700)]
[docs][NewPM] Add example C++ code on how to actually use the new PM

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

2 years ago[LLVM] Inclusive terms: remove/replace references to sanity in RewriteStatepointsForG...
Zarko Todorovski [Mon, 25 Oct 2021 20:05:39 +0000 (16:05 -0400)]
[LLVM] Inclusive terms: remove/replace references to sanity in RewriteStatepointsForGC.cpp and test

Part of work to have the LLVM backend to use more inclusive terms.

Reviewed By: reames

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

2 years ago[BasicAA] Add test for benign range overflow (NFC)
Nikita Popov [Mon, 25 Oct 2021 20:08:56 +0000 (22:08 +0200)]
[BasicAA] Add test for benign range overflow (NFC)

2 years ago[DomTree][NFC] Clean up nits in DomTree code
Jakub Kuderski [Mon, 25 Oct 2021 20:04:42 +0000 (16:04 -0400)]
[DomTree][NFC] Clean up nits in DomTree code

Reviewed By: nikic

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

2 years ago[ELF][X86] Support R_X86_64_PLTOFF64
Fangrui Song [Mon, 25 Oct 2021 20:05:17 +0000 (13:05 -0700)]
[ELF][X86] Support R_X86_64_PLTOFF64

For a function call (using the default `-fplt`), GCC `-mcmodel=large` generates an assembly modifier which
leads to an R_X86_64_PLTOFF64 relocation. In real world,
http://git.ageinghacker.net/jitter (used by GNU poke) uses `-mcmodel=large`.

R_X86_64_PLTOFF64's formula is (if preemptible) `L - GOT + A` or (if non-preemptible) `S - GOT + A`
where `GOT` is (confusingly) the address of `.got.plt`

Reviewed By: peter.smith

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

2 years ago[ELF] Support 128-bit bitmask in oneof(RelExpr)
Fangrui Song [Mon, 25 Oct 2021 19:59:20 +0000 (12:59 -0700)]
[ELF] Support 128-bit bitmask in oneof(RelExpr)

Taken from Chih-Mao Chen's D100835.

RelExpr has 64 bits now and needs the extension to support new members
(`R_PLT_GOTPLT` for `R_X86_64_PLTOFF64` support).

Note: RelExpr needs to have at least a member >=64 to prevent
-Wtautological-constant-out-of-range-compare for `if (expr >= 64)`.

Reviewed By: arichardson, peter.smith

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

2 years ago[clangd] IncludeCleaner: Complicated rules for enum usage
Kirill Bobyrev [Mon, 25 Oct 2021 19:26:37 +0000 (21:26 +0200)]
[clangd] IncludeCleaner: Complicated rules for enum usage

Reviewed By: sammccall

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

2 years ago[ELF] Update comments/diagnostics for some long options to use the canonical two...
Fangrui Song [Mon, 25 Oct 2021 19:52:06 +0000 (12:52 -0700)]
[ELF] Update comments/diagnostics for some long options to use the canonical two-dash form

Rewrite some comments as appropriate.

2 years ago[mlir][Linalg] Allow comprehensive bufferization to use callbacks for alloc/dealloc.
MaheshRavishankar [Mon, 25 Oct 2021 16:00:05 +0000 (09:00 -0700)]
[mlir][Linalg] Allow comprehensive bufferization to use callbacks for alloc/dealloc.

Using callbacks for allocation/deallocation allows users to override
the default.
Also add an option to comprehensive bufferization pass to use `alloca`
instead of `alloc`s. Note that this option is just for testing. The
option to use `alloca` does not work well with the option to allow for
returning memrefs.

2 years ago[x86] add tests for vector -1 constant materialization; NFC
Sanjay Patel [Mon, 25 Oct 2021 14:43:04 +0000 (10:43 -0400)]
[x86] add tests for vector -1 constant materialization; NFC

2 years ago[ELF] Delete unneeded hack for discarding empty name local symbol
Fangrui Song [Mon, 25 Oct 2021 18:55:31 +0000 (11:55 -0700)]
[ELF] Delete unneeded hack for discarding empty name local symbol

This actually improves GNU ld compatibility.
Correct assemblers don't create such symbols.

Also simplify the code.

2 years agoAdd modules stats into the "statistics dump" command.
Greg Clayton [Thu, 21 Oct 2021 23:01:00 +0000 (16:01 -0700)]
Add modules stats into the "statistics dump" command.

The new module stats adds the ability to measure the time it takes to parse and index the symbol tables for each module, and reports modules statistics in the output of "statistics dump" along with the path, UUID and triple of the module. The time it takes to parse and index the symbol tables are also aggregated into new top level key/value pairs at the target level.

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

2 years ago[JITLink] Fix warning 'shift count exceeds width' in AArch64 backend
Stefan Gränitz [Mon, 25 Oct 2021 18:41:26 +0000 (20:41 +0200)]
[JITLink] Fix warning 'shift count exceeds width' in AArch64 backend

2 years ago[MLIR][Math] Add erf to math dialect
Boian Petkantchin [Mon, 25 Oct 2021 18:15:13 +0000 (18:15 +0000)]
[MLIR][Math] Add erf to math dialect

Add math.erf lowering to libm call.
Add math.erf polynomial approximation.

Reviewed By: silvas, ezhulenev

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

2 years ago[openmp] Emit deferred diag only when device compilation presents
Wei Wang [Thu, 2 Sep 2021 17:18:06 +0000 (10:18 -0700)]
[openmp] Emit deferred diag only when device compilation presents

There is no need to check for deferred diag when device compilation or target is
not given. This results in considerable build time improvement in some cases.

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

2 years ago[OpenMP] libomp: disable definitions of 5.1 atomics for non-x86 arch.
AndreyChurbanov [Mon, 25 Oct 2021 18:17:26 +0000 (21:17 +0300)]
[OpenMP] libomp: disable definitions of 5.1 atomics for non-x86 arch.

Declarations of 5.1 atomic entries were added under
"#if KMP_ARCH_X86 || KMP_ARCH_X86_64" in kmp_atomic.h,
but definitions of the functions missed architecture guard in kmp_atomic.cpp.
As a result mangled symbols were available on non-x86 architecture.
The patch eliminates these unexpected symbols from the library.

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

2 years ago[lldb] [DynamicRegisterInfo] Remove AddRegister() and make Finalize() protected
Michał Górny [Sat, 9 Oct 2021 19:22:51 +0000 (21:22 +0200)]
[lldb] [DynamicRegisterInfo] Remove AddRegister() and make Finalize() protected

Now that AddRegister() is no longer used, remove it.  While at it,
we can also make Finalize() protected as all supported API methods
call it internally.

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