platform/upstream/llvm.git
4 years ago[SDAG] Add SDNode::values() = make_range(values_begin(), values_end())
Krzysztof Parzyszek [Wed, 26 Feb 2020 16:54:18 +0000 (10:54 -0600)]
[SDAG] Add SDNode::values() = make_range(values_begin(), values_end())

Also use it in a few places to simplify code a little bit.  NFC

4 years ago[TTI] Let getOperationCost assume that Freeze is free
Juneyoung Lee [Wed, 26 Feb 2020 17:56:01 +0000 (02:56 +0900)]
[TTI] Let getOperationCost assume that Freeze is free

4 years ago[libcxx] Fix _LIBCPP_HAS_THREAD_API_EXTERNAL build
Mikhail Maltsev [Wed, 26 Feb 2020 17:54:43 +0000 (17:54 +0000)]
[libcxx] Fix _LIBCPP_HAS_THREAD_API_EXTERNAL build

Summary:
The definition of `__libcpp_timed_backoff_policy` and the declaration of
`__libcpp_thread_poll_with_backoff` must not be guarded by
  #if !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
because the definitions of `__libcpp_timed_backoff_policy::operator()`
and `__libcpp_thread_poll_with_backoff` aren't guarded by this macro
(and this is correct because these two functions are implemented in
terms of other libc++ functions and don't interact with the host
threading library).

Reviewers: ldionne, __simt__, EricWF, mclow.lists

Reviewed By: ldionne

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

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

4 years agoDevirtualize a call on alloca without waiting for post inline cleanup and next
Hiroshi Yamauchi [Sat, 1 Feb 2020 00:13:44 +0000 (16:13 -0800)]
Devirtualize a call on alloca without waiting for post inline cleanup and next
DevirtSCCRepeatedPass iteration.  Needs ReviewPublic

This aims to fix a missed inlining case.

If there's a virtual call in the callee on an alloca (stack allocated object) in
the caller, and the callee is inlined into the caller, the post-inline cleanup
would devirtualize the virtual call, but if the next iteration of
DevirtSCCRepeatedPass doesn't happen (under the new pass manager), which is
based on a heuristic to determine whether to reiterate, we may miss inlining the
devirtualized call.

This enables inlining in clang/test/CodeGenCXX/member-function-pointer-calls.cpp.

4 years ago[mlir][spirv] NFC: move folders and canonicalizers in a separate file
Lei Zhang [Wed, 26 Feb 2020 14:12:56 +0000 (09:12 -0500)]
[mlir][spirv] NFC: move folders and canonicalizers in a separate file

This gives us better file organization and faster compilation time
by avoid having a gigantic SPIRVOps.cpp file.

4 years ago[compiler-rt] Build all alias in builtin as private external on Darwin
Steven Wu [Wed, 26 Feb 2020 17:17:03 +0000 (09:17 -0800)]
[compiler-rt] Build all alias in builtin as private external on Darwin

Summary:
For builtin compiler-rt, it is built with visibility hidden by default
to avoid the client exporting symbols from libclang static library. The
compiler option -fvisibility=hidden doesn't work on the aliases in c files
because they are created with inline assembly. On Darwin platform,
thoses aliases are exported by default if they are reference by the client.

Fix the issue by adding ".private_extern" to all the aliases if the
library is built with visibility hidden.

rdar://problem/58960296

Reviewers: dexonsmith, arphaman, delcypher, kledzik

Reviewed By: delcypher

Subscribers: dberris, jkorous, ributzka, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[PowerPC][NFC] Convert grep usage to FileCheck in lit test.
Sean Fertile [Wed, 26 Feb 2020 14:52:43 +0000 (09:52 -0500)]
[PowerPC][NFC] Convert grep usage to FileCheck in lit test.

4 years agoUse virtual functions in ParsedAttrInfo instead of function pointers
John Brawn [Wed, 26 Feb 2020 16:31:24 +0000 (16:31 +0000)]
Use virtual functions in ParsedAttrInfo instead of function pointers

This doesn't do anything on its own, but it's the first step towards
allowing plugins to define attributes. It does simplify the
ParsedAttrInfo generation in ClangAttrEmitter a little though.

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

4 years ago[libc] Fix build when -DBUILD_SHARED_LIBS=On
Alex Brachet [Wed, 26 Feb 2020 17:19:09 +0000 (12:19 -0500)]
[libc] Fix build when -DBUILD_SHARED_LIBS=On

Reviewers: gchatelet, sivachandra

Reviewed By: gchatelet, sivachandra

Subscribers: libc-commits, mgorny, MaskRay, tschuett

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

4 years agoAvoid SmallString.h include in MD5.h, NFC
Reid Kleckner [Wed, 26 Feb 2020 16:49:53 +0000 (08:49 -0800)]
Avoid SmallString.h include in MD5.h, NFC

Saves 200 includes, which is mostly immaterial.

4 years ago[llvm-objcopy][test] Improve empty section tests
Fangrui Song [Wed, 19 Feb 2020 23:27:59 +0000 (15:27 -0800)]
[llvm-objcopy][test] Improve empty section tests

empty-sections.test: add two tests adapted from @jhenderson's https://reviews.llvm.org/D74755#1882221
strip-non-alloc.test: improve. D74755 will change the attribution of an empty section.

They mostly test the behavior of Object.cpp:sectionWithinSegment : how we attribute sections to segments.
`ParentSegment` can affect some subtle layout decisions.

Reviewed By: jhenderson

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

4 years ago[ELF] --orphan-handling=: don't warn/error for unused synthesized sections
Fangrui Song [Tue, 25 Feb 2020 23:02:04 +0000 (15:02 -0800)]
[ELF] --orphan-handling=: don't warn/error for unused synthesized sections

This makes --orphan-handling= less noisy.
This change also improves our compatibility with GNU ld.

GNU ld special cases .symtab, .strtab and .shstrtab . We need output section
descriptions for .symtab, .strtab and .shstrtab to suppress:

  <internal>:(.symtab) is being placed in '.symtab'
  <internal>:(.shstrtab) is being placed in '.shstrtab'
  <internal>:(.strtab) is being placed in '.strtab'

With --strip-all, .symtab and .strtab can be omitted (note, --strip-all is not compatible with --emit-relocs).

Reviewed By: nickdesaulniers

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

4 years ago[clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations
Kadir Cetinkaya [Wed, 26 Feb 2020 12:39:46 +0000 (13:39 +0100)]
[clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations

Summary:
Get rid of calls to lexer and unnecessary source location
transformations.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[DAGCombiner] avoid narrowing fake fneg vector op
Sanjay Patel [Wed, 26 Feb 2020 16:16:50 +0000 (11:16 -0500)]
[DAGCombiner] avoid narrowing fake fneg vector op

This may inhibit vector narrowing in general, but there's
already an inconsistency in the way that we deal with this
pattern as shown by the test diff.

We may want to add a dedicated function for narrowing fneg.
It's often folded into some other op, so moving it away from
other math ops may cause regressions that we would not see
for normal binops.

See D73978 for more details.

4 years ago[gn build] Port 3c36d8dad57
LLVM GN Syncbot [Wed, 26 Feb 2020 16:09:48 +0000 (16:09 +0000)]
[gn build] Port 3c36d8dad57

4 years agoIntroduce DWARFDataExtractor::getInitialLength
Pavel Labath [Thu, 13 Feb 2020 15:47:31 +0000 (16:47 +0100)]
Introduce DWARFDataExtractor::getInitialLength

Summary:
This patch introduces a function to house the code needed to do the
DWARF64 detection dance. The function decodes the initial length field
and returns it as a pair containing the actual length, and the DWARF
encoding.

This patch does _not_ attempt to handle the problem of detecting lengths
which extend past the size of the section, or cases when reads of a
single contribution accidentally escape beyond its specified length, but
I think it's useful in its own right.

Reviewers: dblaikie, jhenderson, ikudrin

Subscribers: hiraditya, probinson, aprantl, JDevlieghere, llvm-commits

Tags: #llvm

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

4 years agoAdd _LIBCPP_BUILTIN_CONSTANT_P support.
Martijn Vels [Thu, 30 Jan 2020 19:12:44 +0000 (14:12 -0500)]
Add _LIBCPP_BUILTIN_CONSTANT_P support.

Summary:
This change adds the macros _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT and _LIBCPP_BUILTIN_CONSTANT_P to detect compile time constants, and optimze the code accordingly.

A planned usage example:
The implementation of basic_string::assign() can short-cut a compile time known short string assignent into a fast and compact inlined assignment:

```
basic_string::assign(const value_type* __s) {
  if (_LIBCPP_BUILTIN_CONSTANT_P(__s[0]) && length(__s) < __min_cap) {
    copy(pointer(), _s, length(__s) + 1);
    set_size(length(__s));
  } else {
    // delegate / tail call out of line implementation
  }
}
```

Subscribers: christof, libcxx-commits

Tags: #libc

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

4 years ago[AArch64] add tests for fake fneg; NFC
Sanjay Patel [Wed, 26 Feb 2020 15:55:15 +0000 (10:55 -0500)]
[AArch64] add tests for fake fneg; NFC

See comments in D73978 for background.

4 years agoAdd unit tests for RangeDataVector::FindEntryIndexesThatContain
Unnar Freyr Erlendsson [Wed, 26 Feb 2020 15:43:43 +0000 (16:43 +0100)]
Add unit tests for RangeDataVector::FindEntryIndexesThatContain

Summary: This adds unit tests for FindEntryIndexesThatContain, this is done in preparation for changing the logic of the function.

Reviewers: labath, teemperor

Reviewed By: labath

Subscribers: arphaman, JDevlieghere, lldb-commits

Tags: #lldb

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

4 years ago[DAG] visitRotate - modulo non-uniform constant rotation amounts
Simon Pilgrim [Wed, 26 Feb 2020 15:39:52 +0000 (15:39 +0000)]
[DAG] visitRotate - modulo non-uniform constant rotation amounts

4 years agoRecommit "[DWARFDebugLine] Avoid dumping prologue members we did not parse"
Pavel Labath [Mon, 24 Feb 2020 12:32:31 +0000 (13:32 +0100)]
Recommit "[DWARFDebugLine] Avoid dumping prologue members we did not parse"

The patch was reverted in 69da40033 because of test failures on windows.
The problem was the unpredictable order of some of the error messages,
which I've tried to strenghten in that patch.

It turns out this is not possible to do in verbose mode because there
the data is being writted as it is being parsed. No amount of flushing
(as I've done in the non-verbose mode) will help that. Indeed, even
without any buffering the warning messages can end in the middle of a
line in non-verbose mode.

In this patch, I have reverted the changes which tested the relative
position of the warning message, except for the messages about
unsupported initial length, which are the ones I really wanted to test,
and which do come out reasonably.

The original commit message was:

This patch if motivated by D74560, specifically the subthread about what
to print upon encountering reserved initial length values.

If the debug_line prologue has an unsupported version, we skip parsing
the rest of the data. If we encounter an reserved initial length field,
we don't even parse the version. However, we still print out all members
(with value 0) in the dump function.

This patch introduces early exits in the Prologue::dump function so that
we print only the fields that were parsed successfully. In case of an
unsupported version, we skip printing all subsequent prologue fields --
because we don't even know if this version has those fields. In case of a
reserved unit length, we don't print anything -- if the very first field
of the prologue is invalid, it's hard to say if we even have a prologue
to begin with.

Note that the user will still be able to see the invalid/reserved
initial length value in the error message. I've modified (reordered)
debug_line_invalid.test to show that the error message comes straight
after the debug_line offset. I've also added some flush() calls to the
dumping code to ensure this is the case in all situations (without that,
the warnings could get out of sync if the output was not a terminal -- I
guess this is why std::iostreams have the tie() function).

Reviewers: jhenderson, ikudrin, dblaikie

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[clang-format] Special handling of spaces for C# code
Jonathan Coe [Wed, 26 Feb 2020 15:13:09 +0000 (15:13 +0000)]
[clang-format] Special handling of spaces for C# code

Summary:
Ensure that there are spaces around braces '{', '}'.

Ensure that there is a space before and after '=>'.

Ensure that 'async' and 'when' are considered as keywords when inserting spaces.

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir

Tags: #clang-format

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

4 years ago[clangd] use printQualifiedName to skip the inlinenamespace qualifiers.
Haojian Wu [Wed, 26 Feb 2020 14:22:56 +0000 (15:22 +0100)]
[clangd] use printQualifiedName to skip the inlinenamespace qualifiers.

Summary:
symbols in libcpp are inside the inline namespace, printQualifierAsString will
print the inline namespace, which is unexpected.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

4 years agoFull fix for "AMDGPU/SIInsertSkips: Fix the determination of whether early-exit-after...
Nicolai Hähnle [Wed, 26 Feb 2020 15:21:25 +0000 (16:21 +0100)]
Full fix for "AMDGPU/SIInsertSkips: Fix the determination of whether early-exit-after-kill is possible" (hopefully)

Properly preserve the MachineDominatorTree in all cases.

Change-Id: I54cf0c0a20934168a356920ba8ed5097a93c4131

4 years ago[ARM,MVE] Add predicated intrinsics for many unary functions.
Simon Tatham [Wed, 26 Feb 2020 14:10:43 +0000 (14:10 +0000)]
[ARM,MVE] Add predicated intrinsics for many unary functions.

Summary:
This commit adds the predicated MVE intrinsics for the same set of
unary operations that I added in their unpredicated forms in

* D74333 (vrint)
* D74334 (vrev)
* D74335 (vclz, vcls)
* D74336 (vmovl)
* D74337 (vmovn)

but since the predicated versions are a lot more similar to each
other, I've kept them all together in a single big patch. Everything
here is done in the standard way we've been doing other predicated
operations: an IR intrinsic called `@llvm.arm.mve.foo.predicated` and
some isel rules that match that alongside whatever they accept for the
unpredicated version of the same instruction.

In order to write the isel rules conveniently, I've refactored the
existing isel rules for the affected instructions into multiclasses
parametrised by a vector-type class, in the usual way. All those
refactorings are intended to leave the existing isel rules unchanged:
the only difference should be that new ones for the predicated
intrinsics are introduced.

The only tiny infrastructure change I needed in this commit was to
change the implementation of `IntrinsicMX` in `arm_mve_defs.td` so
that the records it defines are anonymous rather than named (and use
`NameOverride` to set the output intrinsic name), which allows me to
call it twice in two multiclasses with the same `NAME` without a
tablegen-time error.

Reviewers: dmgreen, MarkMurrayARM, miyuki, ostannard

Reviewed By: MarkMurrayARM

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

4 years ago[AIX] Remove whitelist checking for ExternalSymbolSDNodes
Xiangling Liao [Wed, 26 Feb 2020 14:42:04 +0000 (09:42 -0500)]
[AIX] Remove whitelist checking for ExternalSymbolSDNodes

Allow all ExternalSymbolSDNode on AIX, and rely on the linker error to find
symbols which we don't have definitions from any library/compiler-rt.

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

4 years agoPut microsoft template parameter shadow warning behind separate flag (PR44794)
Hans Wennborg [Tue, 25 Feb 2020 15:58:36 +0000 (16:58 +0100)]
Put microsoft template parameter shadow warning behind separate flag (PR44794)

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

4 years agoQuick fix for bot failure on "AMDGPU/SIInsertSkips: Fix the determination of whether...
Nicolai Hähnle [Wed, 26 Feb 2020 15:01:57 +0000 (16:01 +0100)]
Quick fix for bot failure on "AMDGPU/SIInsertSkips: Fix the determination of whether early-exit-after-kill is possible"

Apparently the dominator tree update is incorrect, will investigate.

Change-Id: Ie76f8d11b22a552af1f098c893773f3d85e02d4f

4 years ago[libTooling] Add function to determine associated text of a declaration.
Yitzhak Mandelbaum [Wed, 26 Feb 2020 13:14:19 +0000 (08:14 -0500)]
[libTooling] Add function to determine associated text of a declaration.

Summary:
Second attempt -- the first was reverted in commit 0e480b39c66143ad142f9a30d8d40e49d7d7b0ce, because of test breakages. This revision fixes the cause of the test breakages.

Original description follows:
This patch adds `getAssociatedRange` which, for a given decl, computes preceding
and trailing text that would conceptually be associated with the decl by the
reader. This includes comments, whitespace, and separators like ';'.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

4 years agoAMDGPU: Fix some more incorrect check lines
Jay Foad [Wed, 26 Feb 2020 09:46:07 +0000 (09:46 +0000)]
AMDGPU: Fix some more incorrect check lines

4 years agoAMDGPU/SIInsertSkips: Fix the determination of whether early-exit-after-kill is possible
Nicolai Hähnle [Fri, 21 Feb 2020 12:36:01 +0000 (13:36 +0100)]
AMDGPU/SIInsertSkips: Fix the determination of whether early-exit-after-kill is possible

Summary:
The old code made some incorrect assumptions about the order in which
basic blocks are laid out in a function. This could lead to incorrect
early-exits, especially when kills occurred inside of loops.

The new approach is to check whether the point where the conditional
kill occurs dominates all reachable code. If that is the case, there
cannot be any other threads in the wave that are waiting to rejoin
at a later point in the CFG, i.e. if exec=0 at that point, then all
threads really are dead and we can exit the wave.

Make some other minor cleanups to the pass while we're at it.

v2: preserve the dominator tree

Reviewers: arsenm, cdevadas, foad, critson

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

Tags: #llvm

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

Change-Id: Ia0d2b113ac944ad642d1c622b6da1b20aa1aabcc

4 years ago[mlir][Linalg] NFC - Refactor LinalgStructuredOps towards "named" Linalg ops
Nicolas Vasilache [Wed, 26 Feb 2020 14:21:47 +0000 (09:21 -0500)]
[mlir][Linalg] NFC - Refactor LinalgStructuredOps towards "named" Linalg ops

This revision performs some basic refactoring towards more easily defining Linalg "named" ops. Such named ops form the backbone of operations that are ubiquitous in the ML application domain.

4 years ago[OpenCL] Add atomic type builtins
Sven van Haastregt [Wed, 26 Feb 2020 14:08:23 +0000 (14:08 +0000)]
[OpenCL] Add atomic type builtins

Add atomic types and builtins operating on those atomic types to
`-fdeclare-opencl-builtins`.  The _explicit variants are left out of
this commit, as these take enum arguments that are not yet supported
by the `-fdeclare-opencl-builtins` machinery.

4 years ago[gn build] re-"gn format" all gn files
Nico Weber [Wed, 26 Feb 2020 13:38:18 +0000 (08:38 -0500)]
[gn build] re-"gn format" all gn files

4 years ago[Assembler] Allow assembling empty index with non-zero flags
evgeny [Wed, 26 Feb 2020 13:34:11 +0000 (16:34 +0300)]
[Assembler] Allow assembling empty index with non-zero flags

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

4 years ago[gn build] (manually) port 2f6cc21f44e
Nico Weber [Wed, 26 Feb 2020 13:24:02 +0000 (08:24 -0500)]
[gn build] (manually) port 2f6cc21f44e

4 years ago[OpenMP] Fix the test by generating output file in temporary directory
Kirill Bobyrev [Wed, 26 Feb 2020 13:07:13 +0000 (14:07 +0100)]
[OpenMP] Fix the test by generating output file in temporary directory

Related Revison: D74925
Commit: 396b7253944e927878dff2f6321efabb3aaa0f45

4 years ago[clang][Tooling] Add a way to tokenize a FileRange
Kadir Cetinkaya [Fri, 21 Feb 2020 14:15:36 +0000 (15:15 +0100)]
[clang][Tooling] Add a way to tokenize a FileRange

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[clangd] Bump index version number.
Haojian Wu [Wed, 26 Feb 2020 12:43:11 +0000 (13:43 +0100)]
[clangd] Bump index version number.

Summary:
Though we don't have new changes to the index format, we have changes to
symbol collector, e.g. collect marcos, spelled references. Bump the
version to force background-index to rebuild.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[gn build] (manually) merge e058667a2e01
Nico Weber [Wed, 26 Feb 2020 12:33:32 +0000 (07:33 -0500)]
[gn build] (manually) merge e058667a2e01

4 years agoRevert "[compiler-rt] Add a critical section when flushing gcov counters"
Hans Wennborg [Wed, 26 Feb 2020 12:23:56 +0000 (13:23 +0100)]
Revert "[compiler-rt] Add a critical section when flushing gcov counters"

See discussion on PR44792.

This reverts commit 02ce9d8ef5a84bc884de4105eae5f8736ef67634.

It also reverts the follow-up commits
8f46269f0 "[profile] Don't dump counters when forking and don't reset when calling exec** functions"
62c7d8402 "[profile] gcov_mutex must be static"

4 years agotsan: fix pthread_detach with called_from_lib suppressions
Dmitry Vyukov [Wed, 19 Feb 2020 13:18:53 +0000 (14:18 +0100)]
tsan: fix pthread_detach with called_from_lib suppressions

Generally we ignore interceptors coming from called_from_lib-suppressed libraries.
However, we must not ignore critical interceptors like e.g. pthread_create,
otherwise runtime will lost track of threads.
pthread_detach is one of these interceptors we should not ignore as it affects
thread states and behavior of pthread_join which we don't ignore as well.
Currently we can produce very obscure false positives. For more context see:
https://groups.google.com/forum/#!topic/thread-sanitizer/ecH2P0QUqPs
The added test captures this pattern.

While we are here rename ThreadTid to ThreadConsumeTid to make it clear that
it's not just a "getter", it resets user_id to 0. This lead to confusion recently.

Reviewed in https://reviews.llvm.org/D74828

4 years ago[AArch64][SVE] Add SVE2 intrinsics for bit permutation & table lookup
Kerry McLaughlin [Wed, 26 Feb 2020 09:49:50 +0000 (09:49 +0000)]
[AArch64][SVE] Add SVE2 intrinsics for bit permutation & table lookup

Summary:
Implements the following intrinsics:
 - @llvm.aarch64.sve.bdep.x
 - @llvm.aarch64.sve.bext.x
 - @llvm.aarch64.sve.bgrp.x
 - @llvm.aarch64.sve.tbl2
 - @llvm.aarch64.sve.tbx

The SelectTableSVE2 function in this patch is used to select the TBL2
intrinsic & ensures that the vector registers allocated are consecutive.

Reviewers: sdesmalen, andwar, dancgr, cameron.mcinally, efriedma, rengolin

Reviewed By: efriedma

Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, cfe-commits, llvm-commits

Tags: #llvm

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

4 years ago[ARM][RDA] add getUniqueReachingMIDef
Sam Parker [Wed, 26 Feb 2020 11:14:54 +0000 (11:14 +0000)]
[ARM][RDA] add getUniqueReachingMIDef

Add getUniqueReachingMIDef to RDA which performs a global search for
a machine instruction that produces a unique definition of a given
register at a given point. Also add two helper functions
(getMIOperand) that wrap around this functionality to get the
incoming definition uses of a given instruction. These now replace
the uses of getReachingMIDef in ARMLowOverheadLoops. getReachingMIDef
has been renamed to getReachingLocalMIDef and has been made private
along with getInstFromId.

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

4 years ago[AArch64] Flip default for register renaming in the ld/st optimizier.
Florian Hahn [Wed, 26 Feb 2020 11:05:59 +0000 (11:05 +0000)]
[AArch64] Flip default for register renaming in the ld/st optimizier.

Turn on register renaming again after disabling it for the 10.0 release,
to help flushing out any issues.

4 years ago[docs][llvm-objcopy][llvm-strip] Move --wildcard description earlier
James Henderson [Wed, 26 Feb 2020 10:36:08 +0000 (10:36 +0000)]
[docs][llvm-objcopy][llvm-strip] Move --wildcard description earlier

This moves it above the response file description, which should be at
the end.

4 years ago[docs][llvm-symbolizer] Fix indentation of inline option examples
James Henderson [Wed, 26 Feb 2020 10:29:47 +0000 (10:29 +0000)]
[docs][llvm-symbolizer] Fix indentation of inline option examples

The examples for different options were inconsistently indented in
the HTML display. As they are tied to the options, this change
normalises to indent them the same as the option description body.

4 years ago[docs][llvm-symbolizer] Fix --functions description
James Henderson [Wed, 26 Feb 2020 10:24:50 +0000 (10:24 +0000)]
[docs][llvm-symbolizer] Fix --functions description

"--functions none" and "--functions=none" are not the same. One is the
option "--functions" with its default value of "linkage", followed by an
input address of "none", and the other is "--functions" with the value
"none". This patch fixes the doc to match the actual behaviour by adding
an extra '=' sign in the allowed values description.

4 years agoAMDGPU: Fix some incorrect FUNC-LABEL checks
Jay Foad [Wed, 26 Feb 2020 09:41:41 +0000 (09:41 +0000)]
AMDGPU: Fix some incorrect FUNC-LABEL checks

4 years agoFix typo in clang lit config
serge-sans-paille [Wed, 26 Feb 2020 09:37:04 +0000 (10:37 +0100)]
Fix typo in clang lit config

Typo introduced in e058667a2e017d3225a9bb067dbac7f2159576f7

4 years agoSupport -fuse-ld=lld for riscv
serge-sans-paille [Mon, 17 Feb 2020 12:42:00 +0000 (13:42 +0100)]
Support -fuse-ld=lld for riscv

Add a configure feature test to filter out tests that explicitly depend on platform linker.

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

4 years ago[lldb/gdb-remote] Add support for the qOffsets packet
Pavel Labath [Thu, 13 Feb 2020 13:30:04 +0000 (14:30 +0100)]
[lldb/gdb-remote] Add support for the qOffsets packet

Summary:
This packet is necessary to make lldb work with the remote-gdb stub in
user mode qemu when running position-independent binaries. It reports
the relative position (load bias) of the loaded executable wrt. the
addresses in the file itself.

Lldb needs to know this information in order to correctly set the load
address of the executable. Normally, lldb would be able to find this out
on its own by following the breadcrumbs in the process auxiliary vector,
but we can't do this here because qemu does not support the
qXfer:auxv:read packet.

This patch does not implement full scope of the qOffsets packet (it only
supports packets with identical code, data and bss offsets), because it
is not fully clear how should the different offsets be handled and I am
not aware of a producer which would make use of this feature (qemu will
always
<https://github.com/qemu/qemu/blob/master/linux-user/elfload.c#L2436>
return the same value for code and data offsets). In fact, even gdb
ignores the offset for the bss sections, and uses the "data" offset
instead.  So, until the we need more of this packet, I think it's best
to stick to the simplest solution possible. This patch simply rejects
replies with non-uniform offsets.

Reviewers: clayborg, jasonmolenda

Subscribers: lldb-commits

Tags: #lldb

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

4 years agoFix the clangd-fuzzer build error.
Haojian Wu [Wed, 26 Feb 2020 09:12:49 +0000 (10:12 +0100)]
Fix the clangd-fuzzer build error.

4 years ago[clangd] Expose the rename LimitFiles option to the C++ API, NFC.
Haojian Wu [Wed, 19 Feb 2020 14:37:36 +0000 (15:37 +0100)]
[clangd] Expose the rename LimitFiles option to the C++ API, NFC.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

4 years agoStrip preceeding -Xclang when stripping -fcolor-diagnostics or -fdiagnostics-color
Kadir Cetinkaya [Wed, 26 Feb 2020 08:03:03 +0000 (09:03 +0100)]
Strip preceeding -Xclang when stripping -fcolor-diagnostics or -fdiagnostics-color

Summary: Fixes https://github.com/clangd/clangd/issues/279. We were removing the color options but not the preceeding -Xclang which causes errors since the -Xclang would now apply to the next option in the list of options. Now, when removing a color option, we check if there was a preceeding -Xclang and remove it as well.

Patch By @DaanDeMeyer !

Reviewers: sammccall, kadircet

Reviewed By: sammccall

Subscribers: ilya-biryukov, usaxena95

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

4 years agoRemove no un-necessary require for load_extension.ll
serge-sans-paille [Wed, 26 Feb 2020 07:26:53 +0000 (08:26 +0100)]
Remove no un-necessary require for load_extension.ll

Local testing on OSX no longer exhibit the linking error mentioned in
https://reviews.llvm.org/D71959#1860286

4 years agoAdd missing dependency to fix shared library build.
Michael Liao [Wed, 26 Feb 2020 06:58:12 +0000 (01:58 -0500)]
Add missing dependency to fix shared library build.

4 years ago[SimpleLoopUnswitch] Canonicalize variable names
Juneyoung Lee [Wed, 26 Feb 2020 06:33:02 +0000 (15:33 +0900)]
[SimpleLoopUnswitch] Canonicalize variable names

4 years ago[ARC][NFC] Remove trailing space
Jim Lin [Tue, 25 Feb 2020 08:12:22 +0000 (16:12 +0800)]
[ARC][NFC] Remove trailing space

4 years agoAdd a llvm-gsymutil tool that can convert object files to GSYM and perform lookups.
Greg Clayton [Thu, 20 Feb 2020 01:31:27 +0000 (17:31 -0800)]
Add a llvm-gsymutil tool that can convert object files to GSYM and perform lookups.

Summary:
This patch creates the llvm-gsymutil binary that can convert object files to GSYM using the --convert <path> option. It can also dump and lookup addresses within GSYM files that have been saved to disk.

To dump a file:

llvm-gsymutil /path/to/a.gsym

To perform address lookups, like with atos, on GSYM files:

llvm-gsymutil --address 0x1000 --address 0x1100 /path/to/a.gsym

To convert a mach-o or ELF file, including any DWARF debug info contained within the object files:

llvm-gsymutil --convert /path/to/a.out --out-file /path/to/a.out.gsym

Conversion highlights:
- convert DWARF debug info in mach-o or ELF files to GSYM
- convert symbols in symbol table to GSYM and don't convert symbols that overlap with DWARF debug info
- extract UUID from object files
- extract .text (read + execute) section address ranges and filter out any DWARF or symbols that don't fall in those ranges.
- if .text sections are extracted, and if the last gsym::FunctionInfo object has no size, cap the size to the end of the section the function was contained in

Dumping GSYM files will dump all sections of the GSYM file in textual format.

Reviewers: labath, aadsm, serhiy.redko, jankratochvil, xiaobai, wallace, aprantl, JDevlieghere, jdoerfert

Subscribers: mgorny, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[SimpleLoopUnswitch] Fix introduction of UB when hoisted condition may be undef or...
Juneyoung Lee [Wed, 26 Feb 2020 02:33:34 +0000 (11:33 +0900)]
[SimpleLoopUnswitch] Fix introduction of UB when hoisted condition may be undef or poison

Summary:
Loop unswitch hoists branches on loop-invariant conditions. However, if this
condition is poison/undef and the branch wasn't originally reachable, loop
unswitch introduces UB (since the optimized code will branch on poison/undef and
the original one didn't)).
We fix this problem by freezing the condition to ensure we don't introduce UB.

We will now transform the following:
  while (...) {
    if (C) { A }
    else   { B }
  }

Into:
  C' = freeze(C)
  if (C') {
    while (...) { A }
  } else {
    while (...) { B }
  }

This patch fixes the root cause of the following bug reports (which use the old loop unswitch, but can be reproduced with minor changes in the code and -enable-nontrivial-unswitch):
- https://llvm.org/bugs/show_bug.cgi?id=27506
- https://llvm.org/bugs/show_bug.cgi?id=31652

Reviewers: reames, majnemer, chenli, sanjoy, hfinkel

Reviewed By: reames

Subscribers: hiraditya, jvesely, nhaehnle, filcab, regehr, trentxintong, nlopes, llvm-commits, mzolotukhin

Tags: #llvm

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

4 years ago[PowerPC] Fix the unexpected modification caused by D62993 in LowerSELECT_CC for...
Kang Zhang [Wed, 26 Feb 2020 02:59:03 +0000 (02:59 +0000)]
[PowerPC] Fix the unexpected modification caused by D62993 in LowerSELECT_CC for power9

Summary:
The patch D62993 : `[PowerPC] Emit scalar min/max instructions with unsafe fp math`
has modified the functionality when `Subtarget.hasP9Vector() && (!HasNoInfs || !HasNoNaNs)`,
 this modification is not expected.

Reviewed By: nemanjai

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

4 years ago[MC] Default MCContext::UseNamesOnTempLabels to false and only set it to true for...
Fangrui Song [Tue, 25 Feb 2020 02:09:27 +0000 (18:09 -0800)]
[MC] Default MCContext::UseNamesOnTempLabels to false and only set it to true for MCAsmStreamer

Only MCAsmStreamer (assembly output) needs to keep names of temporary labels created by
MCContext::createTempSymbol().

This change made the rL236642 optimization available for cc2as and
probably some other users.

This eliminates a behavior difference between llvm-mc -filetype=obj and cc1as, which caused
https://reviews.llvm.org/D74006#1890487

Reviewed By: efriedma

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

4 years ago[MC][ARM] Don't create multiple .ARM.exidx associated to one .text
Fangrui Song [Tue, 25 Feb 2020 01:54:39 +0000 (17:54 -0800)]
[MC][ARM] Don't create multiple .ARM.exidx associated to one .text

Fixed an issue exposed by D74006.

In clang cc1as, MCContext::UseNamesOnTempLabels is true.
When parsing a .fnstart directive, FnStart gets redefined to a temporary symbol of a different name (.Ltmp0, .Ltmp1, ...).
MCContext::getELFSection() called by SwitchToEHSection() will create a different .ARM.exidx each time.

llvm-mc uses `Ctx.setUseNamesOnTempLabels(false);` and FnStart is unnamed.
MCContext::getELFSection() called by SwitchToEHSection() will reuse the same .ARM.exidx .

Reviewed By: efriedma

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

4 years ago[Analysis] Fix -Wrange-loop-analysis after D69876
Fangrui Song [Wed, 26 Feb 2020 02:03:47 +0000 (18:03 -0800)]
[Analysis] Fix -Wrange-loop-analysis after D69876

4 years ago[docs] dump-ast-matchers removes const from Matcher args and handles template functio...
Nathan James [Wed, 26 Feb 2020 01:56:21 +0000 (01:56 +0000)]
[docs] dump-ast-matchers removes const from Matcher args and handles template functions slightly better

Reviewers: aaron.ballman, gribozavr2, joerg

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

4 years agoRemove namespace lld { namespace coff { from COFF LLD cpp files
Reid Kleckner [Thu, 20 Feb 2020 01:05:42 +0000 (17:05 -0800)]
Remove namespace lld { namespace coff { from COFF LLD cpp files

Instead, use `using namespace lld(::coff)`, and fully qualify the names
of free functions where they are defined in cpp files.

This effectively reverts d79c3be618 to follow the new style guide added
in 236fcbc21a7a8872.

Reviewed By: MaskRay

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

4 years ago[compiler-rt] Fix a typo in a comment in FuzzedDataProvider.h.
Max Moroz [Wed, 26 Feb 2020 01:10:16 +0000 (17:10 -0800)]
[compiler-rt] Fix a typo in a comment in FuzzedDataProvider.h.

4 years ago[SelectionDAG][PowerPC][AArch64][X86][ARM] Add chain input and output the ISD::FLT_RO...
Craig Topper [Wed, 26 Feb 2020 00:57:42 +0000 (16:57 -0800)]
[SelectionDAG][PowerPC][AArch64][X86][ARM] Add chain input and output the ISD::FLT_ROUNDS_

This node reads the rounding control which means it needs to be ordered properly with operations that change the rounding control. So it needs to be chained to maintain order.

This patch adds a chain input and output to the node and connects it to the chain in SelectionDAGBuilder. I've update all in-tree targets to connect their chain through their lowering code.

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

4 years agoRemove std::shared_ptr::allocate_shared
zoecarver [Wed, 26 Feb 2020 00:50:57 +0000 (16:50 -0800)]
Remove std::shared_ptr::allocate_shared

std::shared_ptr::allocate_shared isn't in the standard. This commit removes it from libc++. It updates std::allocate_shared to use __create_with_cntrl_block.

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

4 years ago[ORC] Remove the JITDylib::SymbolTableEntry::isInMaterializingState() method.
Lang Hames [Wed, 26 Feb 2020 00:04:41 +0000 (16:04 -0800)]
[ORC] Remove the JITDylib::SymbolTableEntry::isInMaterializingState() method.

It was being used inconsistently. Uses have been replaced with direct checks
on the symbol state.

4 years agoFix a null dereference in the LLDB data formatters.
Adrian Prantl [Wed, 26 Feb 2020 00:42:53 +0000 (16:42 -0800)]
Fix a null dereference in the LLDB data formatters.

4 years agoRevert "[libTooling] Add function to determine associated text of a declaration."
Nico Weber [Wed, 26 Feb 2020 00:21:52 +0000 (19:21 -0500)]
Revert "[libTooling] Add function to determine associated text of a declaration."

This reverts commit 9c54f6154f748e707ad2385ddf6d66e812890c6a.
Breaks two tests on Windows, see e.g.
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/14505/steps/stage%201%20check/logs/stdio

4 years ago[GISel][KnownBits] Update a comment regarding the effect of cache on PHIs
Quentin Colombet [Tue, 25 Feb 2020 22:03:21 +0000 (14:03 -0800)]
[GISel][KnownBits] Update a comment regarding the effect of cache on PHIs

Unlike what I claimed in my previous commit. The caching is
actually not NFC on PHIs.

When we put a big enough max depth, we end up simulating loops.
The cache is effectively cutting the simulation short and we
get less information as a result.
E.g.,
```
v0 = G_CONSTANT i8 0xC0
jump
v1 = G_PHI i8 v0, v2
v2 = G_LSHR i8 v1, 1
```

Let say we want the known bits of v1.
- With cache:
Set v1 cache to we know nothing
v1 is v0 & v2
v0 gives us 0xC0
v2 gives us known bits of v1 >> 1
v1 is in the cache
=> v1 is 0, thus v2 is 0x80
Finally v1 is v0 & v2 => 0x80

- Without cache and enough depth to do two iteration of the loop:
v1 is v0 & v2
v0 gives us 0xC0
v2 gives us known bits of v1 >> 1
v1 is v0 & v2
v0 is 0xC0
v2 is v1 >> 1
Reach the max depth for v1...
unwinding
v1 is know nothing
v2 is 0x80
v0 is 0xC0
v1 is 0x80
v2 is 0xC0
v0 is 0xC0
v1 is 0xC0

Thus now v1 is 0xC0 instead of 0x80.

I've added a unittest demonstrating that.

NFC

4 years ago[mlir] [VectorOps] Add vector.print to EDSC
aartbik [Tue, 25 Feb 2020 22:57:35 +0000 (14:57 -0800)]
[mlir] [VectorOps] Add vector.print to EDSC

Summary: This prepares using the operation in model builder runner.

Reviewers: nicolasvasilache, andydavis1

Reviewed By: nicolasvasilache

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, llvm-commits

Tags: #llvm

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

4 years ago[NFC][libc++] Refactor some future tests to reduce code duplication
Louis Dionne [Tue, 25 Feb 2020 23:15:56 +0000 (18:15 -0500)]
[NFC][libc++] Refactor some future tests to reduce code duplication

The same test was being repeated over and over again.
That's what functions are for.

4 years ago[mlir][DenseElementsAttr] Fix storage size for bfloat16 when parsing from hex.
River Riddle [Tue, 25 Feb 2020 22:56:24 +0000 (14:56 -0800)]
[mlir][DenseElementsAttr] Fix storage size for bfloat16 when parsing from hex.

Summary: bfloat16 is stored internally as a double, so we can't direct use Type::getIntOrFloatBitWidth.

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

4 years agoRe-land Unwind past an interrupt handler correctly on arm or at pc==0
Jason Molenda [Tue, 25 Feb 2020 22:55:47 +0000 (14:55 -0800)]
Re-land Unwind past an interrupt handler correctly on arm or at pc==0

Updated the patch to only fetch $pc on a Return Address-using
target only if we're in a trap frame *and* if there is a saved
location for $pc in the trap frame's unwind rules.  If not,
we fall back to fetching the Return Address register (eg $lr).

Original commit msg:

    Unwind past an interrupt handler correctly on arm or at pc==0

    Fix RegisterContextLLDB::InitializeNonZerothFrame so that it
    will fetch a FullUnwindPlan instead of falling back to the
    architectural default unwind plan -- GetFullUnwindPlan knows
    how to spot a jmp 0x0 that results in a fault, which may be
    the case when we see a trap handler on the stack.

    Fix RegisterContextLLDB::SavedLocationForRegister so that when
    the pc value is requested from a trap handler frame, where we
    have a complete register context available to us, don't provide
    the Return Address register (lr) instead of the pc.  We have
    an actual pc value here, and it's pointing to the instruction
    that faulted.

    Differential revision: https://reviews.llvm.org/D75007
    <rdar://problem/59416588>

4 years ago[libc++] Avoid including <semaphore.h> on Apple
Louis Dionne [Tue, 25 Feb 2020 22:52:34 +0000 (17:52 -0500)]
[libc++] Avoid including <semaphore.h> on Apple

It turns out that <semaphore.h> is not well-behaved, as it transitively
includes <sys/param.h>, and that one defines several non-reserved macros
that clash with some downstream projects in modular builds. For the time
being, using <sys/semaphore.h> instead gives us the declarations we need
without the macros.

rdar://59744472

4 years agoRevert "[X86MCTargetDesc.h] Speculative fix for macro collision with sys/param.h"
Vedant Kumar [Tue, 25 Feb 2020 22:37:59 +0000 (14:37 -0800)]
Revert "[X86MCTargetDesc.h] Speculative fix for macro collision with sys/param.h"

This reverts commit eee22ec3c3712a1089cbdbe66ccf36dd89be507a.

This is not the correct fix, the root cause seems to be a bug in the
stage1 host clang compiler. See https://reviews.llvm.org/D75091 for more
discussion.

4 years ago[clang] Annotating C++'s `operator new` with more attributes
Roman Lebedev [Tue, 25 Feb 2020 22:37:17 +0000 (01:37 +0300)]
[clang] Annotating C++'s `operator new` with more attributes

Summary:
Right now we annotate C++'s `operator new` with `noalias` attribute,
which very much is healthy for optimizations.

However as per [[ http://eel.is/c++draft/basic.stc.dynamic.allocation | `[basic.stc.dynamic.allocation]` ]],
there are more promises on global `operator new`, namely:
* non-`std::nothrow_t` `operator new` *never* returns `nullptr`
* If `std::align_val_t align` parameter is taken, the pointer will also be `align`-aligned
* ~~global `operator new`-returned pointer is `__STDCPP_DEFAULT_NEW_ALIGNMENT__`-aligned ~~ It's more caveated than that.

Supplying this information may not cause immediate landslide effects
on any specific benchmarks, but it for sure will be healthy for optimizer
in the sense that the IR will better reflect the guarantees provided in the source code.

The caveat is `-fno-assume-sane-operator-new`, which currently prevents emitting `noalias`
attribute, and is automatically passed by Sanitizers ([[ https://bugs.llvm.org/show_bug.cgi?id=16386 | PR16386 ]]) - should it also cover these attributes?
The problem is that the flag is back-end-specific, as seen in `test/Modules/explicit-build-flags.cpp`.
But while it is okay to add `noalias` metadata in backend, we really should be adding at least
the alignment metadata to the AST, since that allows us to perform sema checks on it.

Reviewers: erichkeane, rjmccall, jdoerfert, eugenis, rsmith

Reviewed By: rsmith

Subscribers: xbolva00, jrtc27, atanasyan, nlopes, cfe-commits

Tags: #llvm, #clang

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

4 years ago[Sema] Perform call checking when building CXXNewExpr
Roman Lebedev [Tue, 25 Feb 2020 22:36:44 +0000 (01:36 +0300)]
[Sema] Perform call checking when building CXXNewExpr

Summary:
There was even a TODO for this.
The main motivation is to make use of call-site based
`__attribute__((alloc_align(param_idx)))` validation (D72996).

Reviewers: rsmith, erichkeane, aaron.ballman, jdoerfert

Reviewed By: rsmith

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[llvm][TextAPI] rename test vars, NFC
Cyndy Ishida [Fri, 14 Feb 2020 22:05:59 +0000 (14:05 -0800)]
[llvm][TextAPI] rename test vars, NFC

* Conforms to clang tidy

4 years ago[OpenMP][Opt] Combine `struct ident_t*` during deduplication
Johannes Doerfert [Thu, 20 Feb 2020 20:17:43 +0000 (14:17 -0600)]
[OpenMP][Opt] Combine `struct ident_t*` during deduplication

If we deduplicate OpenMP runtime calls we have multiple `ident_t*` that
represent information like source location. So far, we simply kept the
one used by the replacement call. However, as exposed by PR44893, that
can cause problems if we have stack allocated `ident_t` objects. While
we need to revisit the use of these as well, it is clear that we
eventually want to merge source location information in some way. With
this patch we add the infrastructure to do so but without doing the
actual merge. Instead we pick a global `ident_t` from the replaced
calls, if possible, or create a new one with an unknown location
instead.

Reviewed By: JonChesterfield

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

4 years ago[WebAssembly] Simplify extract_vector lowering
Thomas Lively [Sat, 22 Feb 2020 01:54:47 +0000 (17:54 -0800)]
[WebAssembly] Simplify extract_vector lowering

Summary:
Removes patterns that were not doing useful work, changes the
default extract instructions to be the unsigned versions now that
they are enabled by default, fixes PR44988, and adds tests for
sext_inreg lowering.

Reviewers: aheejin

Reviewed By: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

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

4 years ago[libTooling] Add function to determine associated text of a declaration.
Yitzhak Mandelbaum [Fri, 3 Jan 2020 14:57:33 +0000 (09:57 -0500)]
[libTooling] Add function to determine associated text of a declaration.

Summary:
This patch adds `getAssociatedRange` which, for a given decl, computes preceding
and trailing text that would conceptually be associated with the decl by the
reader. This includes comments, whitespace, and separators like ';'.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[ObjC][ARC] Don't move a retain call living outside a loop into the loop
Akira Hatanaka [Tue, 25 Feb 2020 20:20:07 +0000 (12:20 -0800)]
[ObjC][ARC] Don't move a retain call living outside a loop into the loop
body

We started seeing cases where ARC optimizer would move retain calls into
loop bodies, causing imbalance in the number of retain and release
calls, after changes were made to delete inert ARC calls since the inert
calls that used to block code motion are gone.

Fix the bug by setting the CFG hazard flag when visiting a loop header.

rdar://problem/56908836

4 years ago[LIBOMPTARGET]Fix PR44933: fix crash because of the too early deinitialization of...
Alexey Bataev [Wed, 19 Feb 2020 14:41:50 +0000 (09:41 -0500)]
[LIBOMPTARGET]Fix PR44933: fix crash because of the too early deinitialization of libomptarget.

Summary:
Instead of using global variables with unpredicted time of
deinitialization, use dynamically allocated variables with functions
explicitly marked as global constructor/destructor and priority. This
allows to prevent the crash because of the incorrect order of dynamic
libraries deinitialization.

Reviewers: grokos, hfinkel

Subscribers: caomhin, kkwli0, openmp-commits

Tags: #openmp

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

4 years ago[X86] Add test to show incorrect ordering of flt.rounds intrinsic relative to calls...
Craig Topper [Tue, 25 Feb 2020 20:22:38 +0000 (12:22 -0800)]
[X86] Add test to show incorrect ordering of flt.rounds intrinsic relative to calls to fesetround.

We don't order flt.rounds intrinsics relative to side effecting
operations in SelectionDAG. And we CSE multiple calls because of
this.

4 years agoCheck args passed to __builtin_frame_address and __builtin_return_address.
zoecarver [Tue, 25 Feb 2020 20:42:49 +0000 (12:42 -0800)]
Check args passed to __builtin_frame_address and __builtin_return_address.

Verifies that an argument passed to __builtin_frame_address or __builtin_return_address is within the range [0, 0xFFFF]

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

Re-committed after fixed: c93112dc4f745b0455addb54bfe1c2f79b827c6d

4 years agoUse "nop" to avoid size warnings.
Bill Wendling [Tue, 25 Feb 2020 20:31:20 +0000 (12:31 -0800)]
Use "nop" to avoid size warnings.

4 years ago[SCEV][IndVars] Always provide insertion point to the SCEVExpander::isHighCostExpansion()
Roman Lebedev [Tue, 25 Feb 2020 18:53:12 +0000 (21:53 +0300)]
[SCEV][IndVars] Always provide insertion point to the SCEVExpander::isHighCostExpansion()

Summary: This addresses the `llvm/test/Transforms/IndVarSimplify/elim-extend.ll` `@nestedIV` regression from D73728

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[SCEV] rewriteLoopExitValues(): even if have hard uses, still rewrite if cheap (PR44668)
Roman Lebedev [Tue, 25 Feb 2020 18:53:00 +0000 (21:53 +0300)]
[SCEV] rewriteLoopExitValues(): even if have hard uses, still rewrite if cheap (PR44668)

Summary:
Replacing uses of IV outside of the loop is likely generally useful,
but `rewriteLoopExitValues()` is cautious, and if it isn't told to always
perform the replacement, and there are hard uses of IV in loop,
it doesn't replace.

In [[ https://bugs.llvm.org/show_bug.cgi?id=44668 | PR44668 ]],
that prevents `-indvars` from replacing uses of induction variable
after the loop, which might be one of the optimization failures
preventing that code from being vectorized.

Instead, now that the cost model is fixed, i believe we should be
a little bit more optimistic, and also perform replacement
if we believe it is within our budget.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=44668 | PR44668 ]].

Reviewers: reames, mkazantsev, asbirlea, fhahn, skatkov

Reviewed By: mkazantsev

Subscribers: nikic, hiraditya, zzheng, javed.absar, dmgreen, llvm-commits

Tags: #llvm

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

4 years ago[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model min/max (PR44668)
Roman Lebedev [Tue, 25 Feb 2020 18:52:46 +0000 (21:52 +0300)]
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model min/max (PR44668)

Summary:
Previosly we simply always said that `SCEVMinMaxExpr` is too costly to expand.
But this isn't really true, it expands into just a comparison+swap pair.
And again much like with add/mul, there will be one less such pair
than the number of operands. And we need to count the cost of operands themselves.

This does change a number of testcases, and as far as i can tell,
all of these changes are improvements, in the sense that
we fixed up more latches to do the [in]equality comparison.

This concludes cost-modelling changes, no other SCEV expressions exist as of now.

This is a part of addressing [[ https://bugs.llvm.org/show_bug.cgi?id=44668 | PR44668 ]].

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

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

4 years ago[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model polynomial recurrence
Roman Lebedev [Tue, 25 Feb 2020 18:52:32 +0000 (21:52 +0300)]
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model polynomial recurrence

Summary:
So, i wouldn't call this *obviously* correct,
but i think i got it right this time :)

Roughly, we have
```
Op0*x^0 + Op1*x^1 + Op2*x^2 ...
```
where `Op_{n} * x^{n}` is called term, and `n` the degree of term.

Due to the way they are stored internally in `SCEVAddRecExpr`,
i believe we can have `Op_{n}` to be `0`, so we should not charge for those.

I think it is most straight-forward to count the cost in 4 steps:
1. First, count it the same way we counted `scAddExpr`, but be sure to skip terms with zero constants.
   Much like with `add` expr we will have one less addition than number of terms.
2. Each non-constant term (term degree >= 1) requires a multiplication between the `Op_{n}` and `x^{n}`.
   But again, only charge for it if it is required - `Op_{n}` must not be 0 (no term) or 1 (no multiplication needed),
   and obviously don't charge constant terms (`x^0 == 1`).
3. We must charge for all the `x^0`..`x^{poly_degree}` themselves.
   Since `x^{poly_degree}` is `x * x * ...  * x`, i.e. `poly_degree` `x`'es multiplied,
   for final `poly_degree` term we again require `poly_degree-1` multiplications.
   Note that all the `x^{0}`..`x^{poly_degree-1}` will be computed for the free along the way there.
4. And finally, the operands themselves.

Here, much like with add/mul exprs, we really don't look for preexisting instructions..

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

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

4 years ago[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model add/mul
Roman Lebedev [Tue, 25 Feb 2020 18:52:19 +0000 (21:52 +0300)]
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model add/mul

Summary:
While this resolves the regression from D73722 in `llvm/test/Transforms/IndVarSimplify/exit_value_test2.ll`,
this now regresses `llvm/test/Transforms/IndVarSimplify/elim-extend.ll` `@nestedIV` test,
we no longer can perform that expansion within default budget of `4`, but require budget of `6`.
That regression is being addressed by D73777.

The basic idea here is simple.
```
Op0,  Op1, Op2 ...
 |     |    |
 \--+--/    |
    |       |
    \---+---/
```
I.e. given N operands, we will have N-1 operations,
so we have to add cost of an add (mul) for **every** Op processed,
**except** the first one, plus we need to recurse into *every* Op.

I'm guessing there's already canonicalization that ensures we won't
have `1` operand in `scMulExpr`, and no `0` in `scAddExpr`/`scMulExpr`.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model plain UDiv
Roman Lebedev [Tue, 25 Feb 2020 18:52:07 +0000 (21:52 +0300)]
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model plain UDiv

Summary:
If we don't believe this UDiv is actually a LShr in disguise, things are much worse.
First, we try to see if this UDiv actually originates from user code,
by looking for `S + 1`, and if found considering this UDiv to be free.
But otherwise, we always considered this UDiv to be high-cost.

However that is no longer the case with TTI-driven cost model:
our default budget is 4, which matches the default cost of UDiv,
so now we allow a single UDiv to not be counted as high-cost.

While that is the case, it is evident this is actually a regression
due to the fact that cost-modelling is incomplete - we did not account
for the `add`, `mul` costs yet. That is being addressed in D73728.

Cost-modelling for UDiv also seems pretty straight-forward:
subtract cost of the UDiv itself, and recurse into both the LHS and RHS.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[NFC][IndVarSimplify] Adjust value names in IndVarSimplify/exit_value_test2.ll
Roman Lebedev [Tue, 25 Feb 2020 19:16:29 +0000 (22:16 +0300)]
[NFC][IndVarSimplify] Adjust value names in IndVarSimplify/exit_value_test2.ll

%tmp prefix confuses auto-update scripts

4 years ago[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model UDiv by power-of-two...
Roman Lebedev [Tue, 25 Feb 2020 18:51:22 +0000 (21:51 +0300)]
[SCEV] SCEVExpander::isHighCostExpansionHelper(): cost-model UDiv by power-of-two as LShr

Summary:
Like with casts, we need to subtract the cost of `lshr` instruction
from budget, and recurse into LHS operand.
Seems "pretty obviously correct" to me?

To be noted, there is a number of other shortcuts we //could// cost-model:
* `... + (-1 * ...)` -> `... - ...` <-  likely very frequent case
* `x - (rem x, power-of-2)`, which is currently `(x udiv power-of-2) * power-of-2` -> `x & -log2(power-of-2)`
* `rem x, power-of-2`, which is currently `x - ((x udiv power-of-2) * power-of-2)` -> `x & log2(power-of-2)-1`
* `... * power-of-2` -> `... << log2(power-of-2)` <- likely not very beneficial

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[SCEV] SCEVExpander::isHighCostExpansionHelper(): begin cost modelling - model cast...
Roman Lebedev [Tue, 25 Feb 2020 18:51:16 +0000 (21:51 +0300)]
[SCEV] SCEVExpander::isHighCostExpansionHelper(): begin cost modelling - model cast cost

Summary:
This is not a NFC, although it does not change any of the existing tests.
I'm not really sure if we should have specific tests for the cost modelling itself.

This is the first patch that actually makes `SCEVExpander::isHighCostExpansionHelper()`
account for the cost of the SCEV expression, and consider the budget available,
by modelling cast expressions.

I believe the logic itself is "pretty obviously correct" - from budget,
we need to subtract the cost of the cast expression from inner type `Op->getType()`
to the `S->getType()` type, and recurse into the expression we are casting.

Reviewers: reames, mkazantsev, wmi, sanjoy

Reviewed By: mkazantsev

Subscribers: xbolva00, hiraditya, javed.absar, llvm-commits

Tags: #llvm

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