platform/upstream/llvm.git
2 years ago[clang] enable sanitizers for hexagon
Brian Cain [Mon, 16 Aug 2021 23:59:42 +0000 (16:59 -0700)]
[clang] enable sanitizers for hexagon

2 years ago[compiler-rt] Add hexagon support to profile
Brian Cain [Tue, 17 Aug 2021 19:41:59 +0000 (12:41 -0700)]
[compiler-rt] Add hexagon support to profile

Adds build support for hexagon linux to profile

2 years ago[compiler-rt] Add hexagon support to safestack
Brian Cain [Tue, 17 Aug 2021 19:41:27 +0000 (12:41 -0700)]
[compiler-rt] Add hexagon support to safestack

Adds build support for hexagon linux to safestack.

2 years ago[compiler-rt] Add hexagon support to CFI
Brian Cain [Tue, 17 Aug 2021 19:40:51 +0000 (12:40 -0700)]
[compiler-rt] Add hexagon support to CFI

Adds build support for hexagon linux to cfi.

2 years ago[sanitizer] Add hexagon support to scudo
Brian Cain [Mon, 16 Aug 2021 23:38:09 +0000 (16:38 -0700)]
[sanitizer] Add hexagon support to scudo

Adds build support for hexagon linux to scudo, scudo-standalone

2 years ago[sanitizer] Add hexagon support to ubsan
Brian Cain [Mon, 16 Aug 2021 23:44:57 +0000 (16:44 -0700)]
[sanitizer] Add hexagon support to ubsan

Adds build support for hexagon linux to ubsan.

2 years ago[sanitizer] Add hexagon support to asan
Brian Cain [Mon, 16 Aug 2021 23:33:21 +0000 (16:33 -0700)]
[sanitizer] Add hexagon support to asan

Adds build support for hexagon linux to asan.

2 years ago[sanitizer] Add hexagon support to lsan
Brian Cain [Mon, 16 Aug 2021 23:28:32 +0000 (16:28 -0700)]
[sanitizer] Add hexagon support to lsan

Adds build support for hexagon linux to lsan.

2 years ago[sanitizer] Add hexagon support to sanitizer-common
Brian Cain [Tue, 17 Aug 2021 21:38:38 +0000 (14:38 -0700)]
[sanitizer] Add hexagon support to sanitizer-common

Adds build support for hexagon linux to sanitizer common.

2 years ago[lldb] Include arm64 in affected_by_radar_34562999
Jonas Devlieghere [Wed, 18 Aug 2021 01:30:48 +0000 (18:30 -0700)]
[lldb] Include arm64 in affected_by_radar_34562999

The same issue impacts arm64, both on-device and on Apple Silicon.

2 years ago[lldb] Extend isAArch64 to arm64 and arm64e
Jonas Devlieghere [Wed, 18 Aug 2021 01:05:46 +0000 (18:05 -0700)]
[lldb] Extend isAArch64 to arm64 and arm64e

This fixes TestMemoryTag on Apple Silicon.

2 years ago[CVP] processSwitch: Remove default case when switch cover all possible values.
Jun Ma [Thu, 15 Jul 2021 10:37:40 +0000 (18:37 +0800)]
[CVP] processSwitch: Remove default case when switch cover all possible values.

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

2 years ago[NFC][CVP] Add one switch testcase
Jun Ma [Tue, 10 Aug 2021 06:52:00 +0000 (14:52 +0800)]
[NFC][CVP] Add one switch testcase

2 years ago[RegAlloc] Remove addAllocPriorityToGlobalRanges hook
Qiu Chaofan [Wed, 18 Aug 2021 02:12:19 +0000 (10:12 +0800)]
[RegAlloc] Remove addAllocPriorityToGlobalRanges hook

It was introduced in 1a6dc92 and only enabled on PowerPC/AMDGPU. That
should be enabled for all targets.

Reviewed By: arsenm

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

2 years ago[DAGCombiner] Teach isKnownToBeAPowerOfTwo handle SPLAT_VECTOR
jacquesguan [Wed, 18 Aug 2021 01:48:33 +0000 (09:48 +0800)]
[DAGCombiner] Teach isKnownToBeAPowerOfTwo handle SPLAT_VECTOR

Make DAGCombine turn mul by power of 2 into shl for scalable vector.

Reviewed By: frasercrmck

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

2 years ago[flang][OpenMP] Add semantic check for target nesting
PeixinQiao [Wed, 18 Aug 2021 01:40:52 +0000 (09:40 +0800)]
[flang][OpenMP] Add semantic check for target nesting

This patch implements the following check for TARGET construct:
```
OpenMP Version 5.0 Target construct restriction: If a target update,
target data, target enter data, or target exit data construct is
encountered during execution of a target region, the behavior is
unspecified.
```

Also add one test case for the check.

Reviewed By: kiranchandramohan, clementval

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

2 years ago[X86] AVX512FP16 instructions enabling 3/6
Wang, Pengfei [Wed, 18 Aug 2021 01:03:01 +0000 (09:03 +0800)]
[X86] AVX512FP16 instructions enabling 3/6

Enable FP16 conversion instructions.

Ref.: https://software.intel.com/content/www/us/en/develop/download/intel-avx512-fp16-architecture-specification.html

Reviewed By: LuoYuanke

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

2 years ago[runtimeunroll] Support multiple exits to latch exit w/epilogue loop
Philip Reames [Wed, 18 Aug 2021 00:50:58 +0000 (17:50 -0700)]
[runtimeunroll] Support multiple exits to latch exit w/epilogue loop

This patch extends the runtime unrolling infrastructure to support unrolling a loop with multiple exiting blocks branching to the same exit block used by the latch. It intentionally does not include a cost model change to enable this functionality unless appropriate force flags are used.

I decided to restrict this to the epilogue case. Given the changes ended up being pretty generic, we may be able to unblock the prolog case too, but I want to do that in a separate change to reduce the amount of code we all have to understand at one time.

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

2 years ago[LLDB][GUI] Add Breakpoints window
Omar Emara [Tue, 17 Aug 2021 23:58:05 +0000 (16:58 -0700)]
[LLDB][GUI] Add Breakpoints window

This patch adds a breakpoints window that lists all breakpoints and
breakpoints locations. The window is implemented as a tree, where the
first level is the breakpoints and the second level is breakpoints
locations.

The tree delegate was hardcoded to only draw when there is a process,
which is not necessary for breakpoints, so the relevant logic was
abstracted in the TreeDelegateShouldDraw method.

Reviewed By: clayborg

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

2 years ago[test] Remove a redundant test line
Philip Reames [Wed, 18 Aug 2021 00:33:12 +0000 (17:33 -0700)]
[test] Remove a redundant test line

This was made redundant when I removed -instcombine from output in 70ffd65c, but I didn't notice.  nikic pointed that out in review of D107381

2 years ago[llvm-profgen] Move profiled binary loading out of PerfReader
wlei [Tue, 17 Aug 2021 22:53:31 +0000 (15:53 -0700)]
[llvm-profgen] Move profiled binary loading out of PerfReader

Change to use unique pointer of profiled binary to unblock asan.

At same time, I realized we can decouple to move the profiled binary loading out of PerfReader, so I made some other related refactors.

Reviewed By: hoy

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

2 years ago[LLDB][GUI] Refactor form drawing using subsurfaces
Omar Emara [Tue, 17 Aug 2021 23:06:46 +0000 (16:06 -0700)]
[LLDB][GUI] Refactor form drawing using subsurfaces

This patch adds a new method SubSurface to the Surface class. The method
returns another surface that is a subset of this surface. This is
important to further abstract away drawing from the ncurses objects. For
instance, fields could previously be drawn on subpads only but can now
be drawn on any surface. This is needed to create the file search
dialogs and similar functionalities.

There is an opportunity to refactor window drawing in general using
surfaces, but we shall consider this separately later.

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

2 years ago[LLDB] Fix off by one logging placeholders in ClangASTSource::layoutRecordType()
Shafik Yaghmour [Tue, 17 Aug 2021 23:29:00 +0000 (16:29 -0700)]
[LLDB] Fix off by one logging placeholders in ClangASTSource::layoutRecordType()

D72391 Added some additional information to the logging but in this case instead of using
placeholder 2 and 3 they used 3 and 4.

2 years ago[Modules] Do not remove failed modules after the control block phase
Ben Barham [Tue, 17 Aug 2021 22:53:40 +0000 (15:53 -0700)]
[Modules] Do not remove failed modules after the control block phase

Reading modules first reads each control block in the chain and then all
AST blocks.

The first phase is intended to find recoverable errors, eg. an out of
date or missing module. If any error occurs during this phase, it is
safe to remove all modules in the chain as no references to them will
exist.

While reading the AST blocks, however, various fields in ASTReader are
updated with references to the module. Removing modules at this point
can cause dangling pointers which can be accessed later. These would be
otherwise harmless, eg. a binary search over `GlobalSLocEntryMap` may
access a failed module that could error, but shouldn't crash. Do not
remove modules in this phase, regardless of failures.

Since this is the case, it also doesn't make sense to return OutOfDate
during this phase, so remove the two cases where this happens.

When they were originally added these checks would return a failure when
the serialized and current path didn't match up. That was updated to an
OutOfDate as it was found to be hit when using VFS and overriding the
umbrella. Later on the path was changed to instead be the name as
written in the module file, resolved using the serialized base
directory. At this point the check is really only comparing the name of
the umbrella and only works for frameworks since those don't include
`Headers/` in the name (which means the resolved path will never exist)

Given all that, it seems safe to ignore this case entirely for now.
This makes the handling of an umbrella header/directory the same as
regular headers, which also don't check for differences in the path
caused by VFS.

Resolves rdar://79329355

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

2 years ago[hwasan] [NFC] pull out helper function.
Florian Mayer [Tue, 3 Aug 2021 10:07:52 +0000 (11:07 +0100)]
[hwasan] [NFC] pull out helper function.

Reviewed By: hctim

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

2 years ago[hwasan] Support malloc in atfork.
Evgenii Stepanov [Sat, 14 Aug 2021 00:09:10 +0000 (17:09 -0700)]
[hwasan] Support malloc in atfork.

Before this change we were locking the StackDepot in the fork()
interceptor. This results in a deadlock when allocator functions are
used in a pthread_atfork() callback.

Instead, set up a pthread_atfork() callback at init that locks/unlocks
both StackDepot and the allocator. Since our callback is set up very
early, the pre-fork callback is executed late, and both post-fork ones
are executed early, which works perfect for us.

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

2 years agoLoopNest Analysis expansion to return instructions that prevent a Loop
Mark Danial [Tue, 17 Aug 2021 22:23:43 +0000 (22:23 +0000)]
LoopNest Analysis expansion to return instructions that prevent a Loop
Nest from being perfect

Expand LoopNestAnalysis to return the full list of instructions that
cause a loop nest to be imperfect. This is useful for other passes to
know if they should continue for in the inner loops.
Added New function getInterveningInstructions
that returns a small vector with the instructions that prevent a loop
for being perfect. Also added a couple of helper functions to reduce
code duplication.

Reviewed By: Whitney

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

2 years ago[flang] Fix the vector version of EOSHIFT with a BOUNDARY argument
Peter Steinfeld [Tue, 17 Aug 2021 21:57:42 +0000 (14:57 -0700)]
[flang] Fix the vector version of EOSHIFT with a BOUNDARY argument

When the vector version of EOSHIFT was called, the BOUNDARY argument was being
ignored.  I fixed that and added a test that would not pass without this fix.

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

2 years ago[libc++abi] Fix possible infinite loop in itanium demangler
Mikhail Borisov [Tue, 17 Aug 2021 22:10:57 +0000 (18:10 -0400)]
[libc++abi] Fix possible infinite loop in itanium demangler

A libfuzzer run has discovered some inputs for which the demangler does
not terminate. When minimized, it looks like this: _Zcv1BIRT_EIS1_E

Deciphered:

_Z
cv    - conversion operator

      * result type
 1B   - "B"
 I    - template args begin
  R   - reference type              <.
   T_ - forward template reference   |  *
 E    - template args end            |  |
                                     |  |
      * parameter type               |  |
 I    - template args begin          |  |
  S1_ - substitution #1              * <'
 E    - template args end

The reason is: template-parameter refs in conversion operator result type
create forward-references, while substitutions are instantly resolved via
back-references. Together these can create a reference loop. It causes an
infinite loop in ReferenceType::collapse().

I see three possible ways to avoid these loops:

1. check if resolving a forward reference creates a loop and reject the
   invalid input (hard to traverse AST at this point)
2. check if a substitution contains a malicious forward reference and
   reject the invalid input (hard to traverse AST at this point;
   substitutions are quite common: may affect performance; hard to
   clearly detect loops at this point)
3. detect loops in ReferenceType::collapse() (cannot reject the input)

This patch implements (3) as seemingly the least-impact change. As a
side effect, such invalid input strings are not rejected and produce
garbage, however there are already similar guards in
`if (Printing) return;` checks.

Fixes https://llvm.org/PR51407

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

2 years ago[libc++abi][NFC] Move PODSmallVector definition to the top of ItaniumDemangle.h
Mikhail Borisov [Tue, 17 Aug 2021 22:06:53 +0000 (18:06 -0400)]
[libc++abi][NFC] Move PODSmallVector definition to the top of ItaniumDemangle.h

This change is needed to clean the non-relevant parts of diff
from https://reviews.llvm.org/D107712

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

2 years ago(NFC) clang-format hwasan/hwasan_linux.cpp
Evgenii Stepanov [Tue, 17 Aug 2021 17:57:25 +0000 (10:57 -0700)]
(NFC) clang-format hwasan/hwasan_linux.cpp

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

2 years agoRevert "Simplify setting up LLVM as bazel external repo"
Geoffrey Martin-Noble [Tue, 17 Aug 2021 21:45:43 +0000 (14:45 -0700)]
Revert "Simplify setting up LLVM as bazel external repo"

This breaks the rules for creating repository dependencies when invoked
from another workspace. See comment on https://reviews.llvm.org/D107714

This reverts commit 934f084ad42231d225bd0eee3342f4b5f7e1ce6e.

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

2 years ago[GlobalOpt] Check stored once value's type before setting global initializer
Arthur Eubanks [Tue, 17 Aug 2021 19:00:45 +0000 (12:00 -0700)]
[GlobalOpt] Check stored once value's type before setting global initializer

In the provided test case, we were trying to set the global's
initializer to `i32* null` when the global's value type was `@0`.

Reviewed By: rnk

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

2 years ago[cmake] Properly support target properties.
Stephen Neuendorffer [Mon, 16 Aug 2021 00:05:25 +0000 (17:05 -0700)]
[cmake] Properly support target properties.

It's sometimes useful to use these directives when dealing with
external projects:
target_link_directories
target_link_libraries
target_include_directories

However, under certain circumstances,
llvm_add_library can generate multiple targets.  We need to transfer
these properties to the new targets.  Note that using a generator
expression is necessary because these properties will only be set
after llvm_add_library is called.

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

2 years ago[libc] Add strtol, strtoul, and strtoull
Michael Jones [Thu, 12 Aug 2021 21:34:02 +0000 (21:34 +0000)]
[libc] Add strtol, strtoul, and strtoull

Updates the internal string conversion function so that it
uses the new Limits.h added in a previous commit for max and min values,
and has a templated type. This makes implementing the other strto*
functions very simple.

Reviewed By: sivachandra

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

2 years ago[X86] EmitInstrWithCustomInserter - silence uninitialized variable warnings. NFCI.
Simon Pilgrim [Tue, 17 Aug 2021 21:00:54 +0000 (22:00 +0100)]
[X86] EmitInstrWithCustomInserter - silence uninitialized variable warnings. NFCI.

Consistently use llvm_unreachable for the default case in the inner switch statements.

2 years agoAdd missing nullptr check
Adrian Prantl [Tue, 17 Aug 2021 20:58:40 +0000 (13:58 -0700)]
Add missing nullptr check

Unfortunatley the IR Verifier doesn't reject debug intrinsics that
have nullptr as arguments, so coro::salvageDebugInfo for now also
needs to deal with them.

rdar://81979541

2 years ago[LICM] Drop -licm-n2-threshold option
Nikita Popov [Tue, 17 Aug 2021 20:34:33 +0000 (22:34 +0200)]
[LICM] Drop -licm-n2-threshold option

This was a diagnostic option used to demonstrate a weakness in
the AST-based LICM implementation. This problem does not exist
in the MSSA-based LICM implementation, which has been enabled
for a long time now. As such, this option is no longer relevant.

2 years ago[llvm-readobj] Refactor ELFDumper::printAttributes()
Jozef Lawrynowicz [Tue, 17 Aug 2021 20:28:31 +0000 (13:28 -0700)]
[llvm-readobj] Refactor ELFDumper::printAttributes()

The current implementation of printAttributes makes it fiddly to extend
attribute support for new targets.

By refactoring the code so all target specific variables are
initialized in a switch/case statement, it becomes simpler to extend
attribute support for new targets.

Reviewed By: jhenderson, MaskRay

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

2 years ago[lldb] Fix#2 of DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used...
Jan Kratochvil [Tue, 17 Aug 2021 20:16:43 +0000 (22:16 +0200)]
[lldb] Fix#2 of DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)

Fix D98289 so that it works even for 2nd..nth compilation unit
(.debug_rnglists).

Reviewed By: dblaikie, ikudrin

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

2 years agoRemove unused imports.
Dan Albert [Tue, 17 Aug 2021 20:03:27 +0000 (13:03 -0700)]
Remove unused imports.

2 years agoSimplify setting up LLVM as bazel external repo
Christian Sigg [Sun, 8 Aug 2021 13:19:33 +0000 (15:19 +0200)]
Simplify setting up LLVM as bazel external repo

Only require one intermediate repository instead of two.
Fewer parameters in llvm_config.
Remove bazel_skylib dependency.

Reviewed By: goncharov

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

2 years ago[mlir][linalg] Don't drop existing attributes when creating ops
Lei Zhang [Tue, 17 Aug 2021 19:44:31 +0000 (15:44 -0400)]
[mlir][linalg] Don't drop existing attributes when creating ops

Reviewed By: mravishankar

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

2 years agoSimplify testcase from c411c1b
Weverything [Tue, 17 Aug 2021 19:07:18 +0000 (12:07 -0700)]
Simplify testcase from c411c1b

2 years ago[PassBuilder] Use loop-mssa for licm
Nikita Popov [Mon, 16 Aug 2021 18:58:31 +0000 (20:58 +0200)]
[PassBuilder] Use loop-mssa for licm

Currently specifying -licm or -passes=licm will implicitly create
-passes=loop(licm). This does not match the intended default (used
by the legacy PM and by the default pipeline) of using the
MemorySSA-based LICM implementation. As I plan to drop the non-MSSA
implementation, this will stop working entirely...

This special-cases licm to create a loop-mssa manager instead. At
this point it's still possible to use -passes='loop(licm)' to opt
into the AST-based implementation.

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

2 years ago[llvm-profgen] Clean up code dealing with multiple binaries
wlei [Thu, 12 Aug 2021 01:01:37 +0000 (18:01 -0700)]
[llvm-profgen] Clean up code dealing with multiple binaries

As we decided to support only one binary each time, this patch cleans up the related code dealing with multiple binaries. We can use `llvm-profdata` to merge profile from multiple binaries.

Reviewed By: hoy, wenlei

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

2 years ago[OpenMP] Fix the usage of sscanf on MinGW
Martin Storsjö [Tue, 17 Aug 2021 10:15:49 +0000 (13:15 +0300)]
[OpenMP] Fix the usage of sscanf on MinGW

KMP_SSCANF only evaluates to sscanf_s within
    #if KMP_OS_WINDOWS && KMP_MSVC_COMPAT
so we need to pass the sscanf_s specific parameters within a similar
condition.

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

2 years ago[sanitizers] Fix building on 32 bit Windows after 7256c05ecb7
Martin Storsjö [Mon, 16 Aug 2021 08:50:10 +0000 (11:50 +0300)]
[sanitizers] Fix building on 32 bit Windows after 7256c05ecb7

On 32 bit, 'long' (which is 32 bit on Windows) is used as base
type for SIZE_T and similar.

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

2 years ago[InstCombine] add TODO about another min/max fold; NFC
Sanjay Patel [Tue, 17 Aug 2021 17:46:08 +0000 (13:46 -0400)]
[InstCombine] add TODO about another min/max fold; NFC

Suggested in post-commit for d0975b7cb0e1

2 years ago[InstCombine] add tests for min/max with 'not' ops; NFC
Sanjay Patel [Tue, 17 Aug 2021 15:38:10 +0000 (11:38 -0400)]
[InstCombine] add tests for min/max with 'not' ops; NFC

2 years ago[RISCV] Use RISCV::RVVBitsPerBlock for RGK_ScalableVector in getRegisterBitWidth.
Craig Topper [Tue, 17 Aug 2021 17:52:34 +0000 (10:52 -0700)]
[RISCV] Use RISCV::RVVBitsPerBlock for RGK_ScalableVector in getRegisterBitWidth.

I might be wrong, but I think this is should be width of the known
min size we use for scalable vectors. It shouldn't scale with
minimum vlen.

Reviewed By: frasercrmck

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

2 years ago[flang] Add missing call to BeginReadingRecord()
peter klausler [Fri, 13 Aug 2021 18:57:58 +0000 (11:57 -0700)]
[flang] Add missing call to BeginReadingRecord()

NAMELIST input needs to start with a call to BeginReadingRecord().
Internal unit input doesn't care (so unit tests were passing), but
external unit input does need the call and will assert without it.

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

2 years agoSelectionDAGBuilder::visitInlineAsm - don't dereference dyn_cast<> results.
Simon Pilgrim [Tue, 17 Aug 2021 17:20:04 +0000 (18:20 +0100)]
SelectionDAGBuilder::visitInlineAsm - don't dereference dyn_cast<> results.

dyn_cast<> can return nullptr if the cast is illegal, use cast<> instead which will assert that the cast is correct.

Fixes static analyser warning.

2 years ago[AArch64] AArch64DAGToDAGISel::tryReadRegister/tryWriteRegister - don't dereference...
Simon Pilgrim [Tue, 17 Aug 2021 17:15:33 +0000 (18:15 +0100)]
[AArch64] AArch64DAGToDAGISel::tryReadRegister/tryWriteRegister - don't dereference dyn_cast<> results.

dyn_cast<> can return nullptr if the cast is illegal, use cast<> instead which will assert that the cast is correct.

Fixes static analyser warnings.

2 years ago[ARM] ARMDAGToDAGISel::tryReadRegister/tryWriteRegister - don't dereference dyn_cast...
Simon Pilgrim [Tue, 17 Aug 2021 17:13:59 +0000 (18:13 +0100)]
[ARM] ARMDAGToDAGISel::tryReadRegister/tryWriteRegister - don't dereference dyn_cast<> results.

dyn_cast<> can return nullptr if the cast is illegal, use cast<> instead which will assert that the cast is correct.

Fixes static analyser warnings.

2 years ago[libc++] Update the version of CMake in the Docker image
Louis Dionne [Tue, 17 Aug 2021 17:35:50 +0000 (13:35 -0400)]
[libc++] Update the version of CMake in the Docker image

2 years agoRevert "[tsan] Fix GCC 8.3 build after D107911"
Marco Elver [Tue, 17 Aug 2021 17:26:19 +0000 (19:26 +0200)]
Revert "[tsan] Fix GCC 8.3 build after D107911"

This reverts commit 797fe59e6b9512652c0ae5a6b69a3c6f5a573fcd.

The use of "EventType type : 3" is replicated for all Event structs and
therefore was still present. As a result this still caused failures on
older GCCs (9.2 or 8.3 or earlier).

The particular bot that was failing due to buggy GCC was fixed by
fef39cc472a773fae4761deaab1c701024ad13ec.

Therefore, no reason to keep the workaround around; revert it.

Reviewed By: vitalybuka

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

2 years agoscan-build-py: Force the opening in utf-8
Sylvestre Ledru [Tue, 17 Aug 2021 17:17:30 +0000 (19:17 +0200)]
scan-build-py: Force the opening in utf-8

It fails on ubuntu bionic otherwise with:
```
scan-build-py-14: Run 'scan-view /tmp/scan-build-2021-08-09-09-14-36-765350-nx9s888s' to examine bug reports.
scan-build-py-14: Internal error.
Traceback (most recent call last):
  File "/usr/lib/llvm-14/lib/libscanbuild/__init__.py", line 125, in wrapper
    return function(*args, **kwargs)
  File "/usr/lib/llvm-14/lib/libscanbuild/analyze.py", line 72, in scan_build
    number_of_bugs = document(args)
  File "/usr/lib/llvm-14/lib/libscanbuild/report.py", line 35, in document
    for bug in read_bugs(args.output, html_reports_available):
  File "/usr/lib/llvm-14/lib/libscanbuild/report.py", line 282, in read_bugs
    for bug in parser(bug_file):
  File "/usr/lib/llvm-14/lib/libscanbuild/report.py", line 421, in parse_bug_html
    for line in handler.readlines():
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3360: ordinal not in range(128)
scan-build-py-14: Please run this command again and turn on verbose mode (add '-vvvv' as argument).
```

I guess it is caused by a problem in Python 3.6

Reviewed By: phosek, isthismyaccount

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

2 years agohwasan: Move stack ring buffer initialization before InitStackAndTls.
Peter Collingbourne [Tue, 17 Aug 2021 03:13:42 +0000 (20:13 -0700)]
hwasan: Move stack ring buffer initialization before InitStackAndTls.

D104248 moved the call to GetThreadStackAndTls to before the
initialization of the ring buffer TLS slot. As a result, if libc
is instrumented we crash in pthread_getattr_np which is called from
__sanitizer::GetThreadStackTopAndBottom.

Fix the problem by moving the stack ring buffer initialization before
the call to InitStackAndTls.

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

2 years ago[flang] Fix regression from recent runtime input fix
peter klausler [Mon, 16 Aug 2021 20:15:01 +0000 (13:15 -0700)]
[flang] Fix regression from recent runtime input fix

A recent runtime I/O change[1] was meant to improve the handling of
input from external files missing a terminal newline on their last
records; the change was "triggered" by the wrong circumstances and
causing reads that should have pulled more data into the buffer to be
treated as EOFs.  So fix that, and also don't retain input data
in the buffer once an input record has been finished unless it's
known that list-directed or NAMELIST input of a repeated input item
may need to backspace a non-positionable external unit to return
to the beginning of the repeated item.

[1] 6578893a0453384346f149479f8574dfff977ace

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

2 years ago[AMDGPU] Fix lowering of AMDGPU::G_CTTZ_ZERO_UNDEF to AMDGPU::G_AMDGPU_FFBL_B32
Simon Pilgrim [Tue, 17 Aug 2021 16:57:01 +0000 (17:57 +0100)]
[AMDGPU] Fix lowering of AMDGPU::G_CTTZ_ZERO_UNDEF to AMDGPU::G_AMDGPU_FFBL_B32

As mentioned on D107474, there was a copy+paste typo repeating G_CTLZ_ZERO_UNDEF that coverity reported as dead code.

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

2 years ago[VP] Add vector-predicated reduction intrinsics
Fraser Cormack [Mon, 14 Jun 2021 08:42:00 +0000 (09:42 +0100)]
[VP] Add vector-predicated reduction intrinsics

This patch adds vector-predicated ("VP") reduction intrinsics corresponding to
each of the existing unpredicated `llvm.vector.reduce.*` versions. Unlike the
unpredicated reductions, all VP reductions have a start value. This start value
is returned when the no vector element is active.

Support for expansion on targets without native vector-predication support is
included.

This patch is based on the ["reduction
slice"](https://reviews.llvm.org/D57504#1732277) of the LLVM-VP reference patch
(https://reviews.llvm.org/D57504).

Reviewed By: craig.topper

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

2 years ago[libc][NFC] Disable double precision cos, sin and tan on Windows.
Siva Chandra Reddy [Tue, 17 Aug 2021 16:42:34 +0000 (16:42 +0000)]
[libc][NFC] Disable double precision cos, sin and tan on Windows.

The current x86_64 implementations do not build on the windows bot
machine. We will enable them back after fixing the problem.

2 years ago[OpenMP][NFC] Add option to print module after OpenMPOpt for debugging
Joseph Huber [Mon, 16 Aug 2021 17:06:54 +0000 (13:06 -0400)]
[OpenMP][NFC] Add option to print module after OpenMPOpt for debugging

This patch adds an extra option to print the module after running one of
the OpenMPOpt passes if debugging is enabled. This makes it much easier
to inspect the effects of this pass when doing debugging.

Reviewed By: jdoerfert

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

2 years ago[SCEVExpander] Stop hoisting IR when reusing phis
Philip Reames [Tue, 17 Aug 2021 16:26:59 +0000 (09:26 -0700)]
[SCEVExpander] Stop hoisting IR when reusing phis

his is a fix for PR43678, and is an alternate patch to D105723.

The basic issue we're running into is that LSR + SCEVExpander are moving the very instruction whose operand we're in the process of expanding. This breaks the subtle and ill-documented invariant which let LSR work. (Full story can be found here: https://reviews.llvm.org/D105723#2878473)

Rather than attempting a fix, this change just removes the optimization entirely. The code is entirely untested, and removing it appears to have no impact I can find.  This code was added back in 2014 by 1e12f8563d4b7 with a single test which does not seem to actually test the hoisting logic.

From a philosophical standpoint, it also seems very strange to have the expander implementing optimizations which should live in a dedicated transform pass.

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

2 years ago[analyzer] Adjust JS code of analyzer's HTML report for IE support.
Denys Petrov [Tue, 3 Aug 2021 16:09:00 +0000 (19:09 +0300)]
[analyzer] Adjust JS code of analyzer's HTML report for IE support.

Summary: Change and replace some functions which IE does not support. This patch is made as a continuation of D92928 revision. Also improve hot keys behavior.

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

2 years agoFix 2: [MCParser] Correctly handle CRLF line ends when consuming line comments
Tozer [Tue, 17 Aug 2021 16:09:44 +0000 (17:09 +0100)]
Fix 2: [MCParser] Correctly handle CRLF line ends when consuming line comments

Fixes an issue with revision 5c6f748c and ad40cb88.

Adds an mcpu argument to the test command, preventing an invalid default
CPU from being used on some platforms.

2 years ago[llvm-objdump] -T: print symbol versions
Fangrui Song [Tue, 17 Aug 2021 16:10:50 +0000 (09:10 -0700)]
[llvm-objdump] -T: print symbol versions

Similar to D94907 (llvm-nm -D).

The output will match GNU objdump 2.37.
Older versions don't use ` (version)` for undefined symbols.

Reviewed By: jhenderson

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

2 years agoAllow setting attributes in build method generated by YAML-gen.
MaheshRavishankar [Tue, 17 Aug 2021 15:59:13 +0000 (08:59 -0700)]
Allow setting attributes in build method generated by YAML-gen.

Reviewed By: gysit

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

2 years ago[Object] Move llvm-nm's symbol version utility to ELFObjectFile::readDynsymVersions
Fangrui Song [Tue, 17 Aug 2021 16:06:39 +0000 (09:06 -0700)]
[Object] Move llvm-nm's symbol version utility to ELFObjectFile::readDynsymVersions

The utility can be reused by llvm-objdump -T.

Reviewed By: jhenderson

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

2 years ago[libc++][NFC] Format expression-equivalent wrappers consistently
Louis Dionne [Mon, 16 Aug 2021 16:41:58 +0000 (12:41 -0400)]
[libc++][NFC] Format expression-equivalent wrappers consistently

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

2 years ago[X86] Lower insertions into upper half of an 256-bit vector as broadcast+blend (PR50971)
Roman Lebedev [Tue, 17 Aug 2021 15:42:22 +0000 (18:42 +0300)]
[X86] Lower insertions into upper half of an 256-bit vector as broadcast+blend (PR50971)

Broadcast is not worse than extract+insert of subvector.
https://godbolt.org/z/aPq98G6Yh

Reviewed By: RKSimon

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

2 years ago[Polly] Fix possibly infinite loop.
Michael Kruse [Tue, 17 Aug 2021 15:34:59 +0000 (10:34 -0500)]
[Polly] Fix possibly infinite loop.

The loop had no side-effect since first committed in 642594ae87aca.
While it is obvious what was intended, the code seems to never trigger.

2 years ago[scudo] Fix format string specifiers
Kostya Kortchinsky [Mon, 16 Aug 2021 22:23:48 +0000 (15:23 -0700)]
[scudo] Fix format string specifiers

Enable `-Wformat` again, and fix the offending instances.

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

2 years ago[libc++] Do not require movability in __non_propagating_cache::__emplace_deref
Louis Dionne [Wed, 11 Aug 2021 18:26:33 +0000 (14:26 -0400)]
[libc++] Do not require movability in __non_propagating_cache::__emplace_deref

As explained in http://eel.is/c++draft/range.nonprop.cache#note-1, we
should allow copy and move elision to happen when calling emplace_deref
in non-propagating-cache. Before this change, the only way to emplace
into the non-propagating-cache was to call `__set(*it)`, which materialized
`*it` when binding it to the reference argument of `__set` and disabled
move elision.

As a fly-by change, this also renames `__set` to `__emplace` for consistency
and adds tests for it.

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

2 years agoFix: [MCParser] Correctly handle CRLF line ends when consuming line comments
Tozer [Tue, 17 Aug 2021 15:14:12 +0000 (16:14 +0100)]
Fix: [MCParser] Correctly handle CRLF line ends when consuming line comments

Fixes an issue with revision 5c6f748c.

Move the test added in the above commit into the X86 folder, ensuring
that it is only run on targets where its triple is valid.

2 years agotsan: test: Initialize all fields of Params struct
Marco Elver [Tue, 17 Aug 2021 14:54:07 +0000 (16:54 +0200)]
tsan: test: Initialize all fields of Params struct

Some compilers started complaining about the test:

tsan_trace_test.cpp:128:21: error: missing field 'type' initializer

Fix it by initializing all 5 fields, even though the type field will be
reset in the for loop.

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

2 years ago[MCParser] Correctly handle CRLF line ends when consuming line comments
Tozer [Tue, 17 Aug 2021 14:38:45 +0000 (15:38 +0100)]
[MCParser] Correctly handle CRLF line ends when consuming line comments

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

The AsmLexer currently has an issue with lexing line comments in files
with CRLF line endings, in which it reads the carriage return as being
part of the line comment. This causes an error for certain valid comment
layouts; this patch fixes this by excluding the carriage return from the
line comment.

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

2 years ago[libc++][NFC] Fix indentation of documentation
Louis Dionne [Tue, 17 Aug 2021 14:52:12 +0000 (10:52 -0400)]
[libc++][NFC] Fix indentation of documentation

2 years ago[Bitcode] Remove unused declaration writeBitcodeHeader (NFC)
Kazu Hirata [Tue, 17 Aug 2021 14:10:51 +0000 (07:10 -0700)]
[Bitcode] Remove unused declaration writeBitcodeHeader (NFC)

The corresponding definition was removed on Nov 29, 2016 in commit
5a0a2e648c267d99111b21482ca709f580e9ccc2.

2 years ago[LIT]Accept cat_64 command name on AIX in shtest
Jinsong Ji [Tue, 17 Aug 2021 14:05:28 +0000 (14:05 +0000)]
[LIT]Accept cat_64 command name on AIX in shtest

AIX may use cat_64 for 64 bit cat, this is just update the lit test to accept the name as well.

Reviewed By: #powerpc, shchenz

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

2 years ago[SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute
Dylan Fleming [Tue, 17 Aug 2021 13:00:47 +0000 (14:00 +0100)]
[SVE] Remove usage of getMaxVScale for AArch64, in favour of IR Attribute

Removed AArch64 usage of the getMaxVScale interface, replacing it with
the vscale_range(min, max) IR Attribute.

Reviewed By: paulwalker-arm

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

2 years ago[libc++][NFC] Refactor tests for transform_view
Louis Dionne [Tue, 17 Aug 2021 13:20:24 +0000 (09:20 -0400)]
[libc++][NFC] Refactor tests for transform_view

Adjust the names of helper function objects to represent better what
they do, as suggested in the review of D107098.

2 years ago[ARM] Enable subreg liveness
David Green [Tue, 17 Aug 2021 13:10:33 +0000 (14:10 +0100)]
[ARM] Enable subreg liveness

This enables subreg liveness in the arm backend when MVE is present,
which allows the register allocator to detect when subregister are
alive/dead, compared to only acting on full registers. This can helps
produce better code on MVE with the way MQPR registers are made up of
SPR registers, but is especially helpful for MQQPR and MQQQQPR
registers, where there are very few "registers" available and being able
to split them up into subregs can help produce much better code.

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

2 years ago[ARM] Add MQQPR and MQQQQPR spill and reload pseudo instructions
David Green [Tue, 17 Aug 2021 12:51:34 +0000 (13:51 +0100)]
[ARM] Add MQQPR and MQQQQPR spill and reload pseudo instructions

As a part of D107642, this adds pseudo instructions for MQQPR and
MQQQQPR register classes, that can spill and reloads entire registers
whilst keeping them combined, not splitting them into multiple D subregs
that a VLDMIA/VSTMIA would use. This can help certain analyses, and
helps to prevent verifier issues with subreg liveness.

2 years ago[InstCombine] remove unused function argument; NFC
Sanjay Patel [Tue, 17 Aug 2021 12:10:16 +0000 (08:10 -0400)]
[InstCombine] remove unused function argument; NFC

2 years ago[InstCombine] fold signed min/max intrinsics with negated operands
Sanjay Patel [Tue, 17 Aug 2021 11:31:05 +0000 (07:31 -0400)]
[InstCombine] fold signed min/max intrinsics with negated operands

If both operands are negated, we can invert the min/max and do
the negation after:
smax (neg nsw X), (neg nsw Y) --> neg nsw (smin X, Y)
smin (neg nsw X), (neg nsw Y) --> neg nsw (smax X, Y)

This is visible as a remaining regression in D98152. I don't see
a way to generalize this for 'unsigned' or adapt Negator to
handle it. This only appears to be safe with 'nsw':
https://alive2.llvm.org/ce/z/GUy1zJ

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

2 years ago[InstCombine] add tests for smin/smax intrinsics with negated ops; NFC
Sanjay Patel [Mon, 16 Aug 2021 19:27:55 +0000 (15:27 -0400)]
[InstCombine] add tests for smin/smax intrinsics with negated ops; NFC

2 years ago[GlobalISel] Add combine for PTR_ADD with regbanks
Sebastian Neubauer [Tue, 17 Aug 2021 11:58:16 +0000 (13:58 +0200)]
[GlobalISel] Add combine for PTR_ADD with regbanks

Combine two G_PTR_ADDs, but keep the register bank of the constant.
That way, the combine can be used in post-regbank-select combines.

Introduce two helper methods in CombinerHelper, getRegBank and
setRegBank that get and set an optional register bank to a register.
That way, they can be used before and after register bank selection.

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

2 years ago[lldb] Make TestAArch64AdrpAdd depend on the AArch64 target
Raphael Isemann [Tue, 17 Aug 2021 10:46:44 +0000 (12:46 +0200)]
[lldb] Make TestAArch64AdrpAdd depend on the AArch64 target

LLDB is using LLVM's target-specific disassembler which is only available when
the respective LLVM target has been enabled in the build config.

This patch just skips the test if there is no arm64 target (and its
disassembler) available in the current build config.

Reviewed By: jasonmolenda

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

2 years ago[CodeGenPrepare] The instruction to be sunk should be inserted before its user in...
Tiehu Zhang [Tue, 17 Aug 2021 10:50:54 +0000 (18:50 +0800)]
[CodeGenPrepare] The instruction to be sunk should be inserted before its user in a block

In current implementation, the instruction to be sunk will be inserted before the target instruction without considering the def-use tree,
which may case Instruction does not dominate all uses error. We need to choose a suitable location to insert according to the use chain

Reviewed By: dmgreen

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

2 years ago[DebugInfo][InstrRef] Honour too-much-debug-info cutouts
Jeremy Morse [Tue, 17 Aug 2021 10:32:41 +0000 (11:32 +0100)]
[DebugInfo][InstrRef] Honour too-much-debug-info cutouts

This reapplies 54a61c94f93, its follow up in 547b712500e, which were
reverted 95fe61e63954. Original commit message:

VarLoc based LiveDebugValues will abandon variable location propagation if
there are too many blocks and variable assignments in the function. If it
didn't, and we had (say) 1000 blocks and 1000 variables in scope, we'd end
up with 1 million DBG_VALUEs just at the start of blocks.

Instruction-referencing LiveDebugValues should honour this limitation too
(because the same limitation applies to it). Hoist the relevant command
line options into LiveDebugValues.cpp and pass it down into the
implementation classes as an argument to ExtendRanges. I've duplicated all
the run-lines in live-debug-values-cutoffs.mir to have an
instruction-referencing flavour.

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

2 years ago[AArch64] LowerCONCAT_VECTORS - merge getNumOperands() calls. NFCI.
Simon Pilgrim [Tue, 17 Aug 2021 10:22:49 +0000 (11:22 +0100)]
[AArch64] LowerCONCAT_VECTORS - merge getNumOperands() calls. NFCI.

Improves on the unused variable fix from rG4357562067003e25ab343a2d67a60bd89cd66dbf

2 years ago[AggressiveInstCombine] Add shift left instruction to `TruncInstCombine` DAG
Anton Afanasyev [Thu, 12 Aug 2021 11:51:57 +0000 (14:51 +0300)]
[AggressiveInstCombine] Add shift left instruction to `TruncInstCombine` DAG

Add `shl` instruction to the DAG post-dominated by `trunc`, allowing
TruncInstCombine to reduce bitwidth of expressions containing left shifts.

The only thing we need to check is that the target bitwidth must be wider
than the maximal shift amount: https://alive2.llvm.org/ce/z/AwArqu

Part of https://reviews.llvm.org/D107766

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

2 years ago[Test][AggressiveInstCombine] Add test for shifts
Anton Afanasyev [Thu, 12 Aug 2021 11:51:57 +0000 (14:51 +0300)]
[Test][AggressiveInstCombine] Add test for shifts

Precommit test for D107766/D108091. Also move fixed test for PR50555
from SLPVectorizer/X86/ to PhaseOrdering/X86/ subdirectory.

2 years ago[hwasan] Prevent reordering of tag checks.
Florian Mayer [Wed, 11 Aug 2021 13:25:50 +0000 (14:25 +0100)]
[hwasan] Prevent reordering of tag checks.

They were previously unconstrained, which allowed them to be reordered
before the shadow memory write.

Reviewed By: eugenis

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

2 years ago[NFC] Fix typos
PeixinQiao [Tue, 17 Aug 2021 09:16:37 +0000 (17:16 +0800)]
[NFC] Fix typos

Initial commit test.

2 years ago[mlir][linalg] Remove duplicate methods (NFC).
Tobias Gysi [Tue, 17 Aug 2021 07:04:21 +0000 (07:04 +0000)]
[mlir][linalg] Remove duplicate methods (NFC).

Remove duplicate methods used to check iterator types.

Reviewed By: aartbik

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

2 years ago[X86] [AMX] Replace bitcast with specific AMX intrinsics with X86 specific cast.
Bing1 Yu [Thu, 5 Aug 2021 09:01:21 +0000 (17:01 +0800)]
[X86] [AMX] Replace bitcast with specific AMX intrinsics with X86 specific cast.

There is some discussion on the bitcast for vector and x86_amx at https://reviews.llvm.org/D99152. This patch is to introduce a x86 specific cast for vector and x86_amx, so that it can avoid some unnecessary optimization by middle-end. On the other way, we have to optimize the x86 specific cast by ourselves. This patch also optimize the cast operation to eliminate redundant code.

Reviewed By: LuoYuanke

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

2 years agoAMDGPU: During img instruction ret value construction cater for non int values
David Stuttard [Wed, 5 Feb 2020 14:22:18 +0000 (14:22 +0000)]
AMDGPU: During img instruction ret value construction cater for non int values

Make sure return type is int type.

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

Change-Id: Ic02f07d1234cd51b6ed78c3fecd2cb1d6acd5644