platform/upstream/llvm.git
4 years ago[NFC] [AArch64] Fix wrong documentation for IsStoreRegOffsetOp
David Tellenbach [Sat, 23 Nov 2019 18:11:31 +0000 (19:11 +0100)]
[NFC] [AArch64] Fix wrong documentation for IsStoreRegOffsetOp

4 years agoFix llvm-namespace-comment for macro expansions
Marcin Twardak [Sat, 23 Nov 2019 18:08:14 +0000 (13:08 -0500)]
Fix llvm-namespace-comment for macro expansions

If a namespace is a macro name, it should be allowed to close the
namespace with the same name.

4 years ago[lldb][NFC] NFC refactoring ClangExpressionDeclMap::LookupLocalVariable
Raphael Isemann [Sat, 23 Nov 2019 16:01:25 +0000 (17:01 +0100)]
[lldb][NFC] NFC refactoring ClangExpressionDeclMap::LookupLocalVariable

Adding an early exits and moving variable declarations closer to their
actual use.

4 years agoAMDGPU: Handle waitcnt overflow
Austin Kerbow [Sat, 2 Nov 2019 21:48:40 +0000 (14:48 -0700)]
AMDGPU: Handle waitcnt overflow

Summary:
The waitcnt pass can overflow the counters when the number of outstanding events
for a type exceed the capacity of the counter. This can lead to inefficient
insertion of waitcnts, or to waitcnt instructions with max values for each type.
The last situation can cause an instruction which when disassembled appears to
be an illegal waitcnt without an operand.

In these cases we should add a wait for the 'counter maximum' - 1, and update the
waitcnt brackets accordingly.

Reviewers: rampitec, arsenm

Reviewed By: rampitec

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

Tags: #llvm

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

4 years ago[InlineCost] Fix infinite loop in indirect call evaluation
Ehud Katz [Tue, 5 Nov 2019 07:45:51 +0000 (09:45 +0200)]
[InlineCost] Fix infinite loop in indirect call evaluation

Currently every time we encounter an indirect call of a known function,
we try to evaluate the inline cost of that function. In case of a
recursion, that evaluation never stops.

The solution presented is to evaluate only the indirect call of the
function, while any further indirect calls (of a known function) will be
treated just as direct function calls, which, actually, never tries to
evaluate the call.

Fixes PR35469.

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

4 years ago[lldb][NFC] Fix LLDB build after ModuleManager->ASTReader rename
Raphael Isemann [Sat, 23 Nov 2019 16:56:05 +0000 (17:56 +0100)]
[lldb][NFC] Fix LLDB build after ModuleManager->ASTReader rename

That happened in 20d51b2f14ac4488f684f8f but LLDB wasn't updated.

4 years ago[Driver] Fix incorrect GNU triplet for PowerPC on SUSE Linux
Aaron Puchert [Sat, 23 Nov 2019 15:00:36 +0000 (16:00 +0100)]
[Driver] Fix incorrect GNU triplet for PowerPC on SUSE Linux

Summary:
On SUSE distributions for 32-bit PowerPC, gcc is configured
as a 64-bit compiler using the GNU triplet "powerpc64-suse-linux",
but invoked with "-m32" by default. Thus, the correct GNU triplet
for 32-bit PowerPC SUSE distributions is "powerpc64-suse-linux"
and not "powerpc-suse-linux".

Reviewers: jrtc27, nemanjai, glaubitz

Reviewed By: nemanjai

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

4 years agoRecommit "[DWARF] Support for loclist.dwo section in llvm and llvm-dwarfdump."
Sourabh Singh Tomar [Sat, 23 Nov 2019 14:34:36 +0000 (20:04 +0530)]
Recommit "[DWARF] Support for loclist.dwo section in llvm and llvm-dwarfdump."

The original commit message follows.

This patch adds support for debug_loclists.dwo section in llvm and llvm-dwarfdump.
Also Fixes PR43622, PR43623.

Reviewers: dblaikie, probinson, labath, aprantl, jini.susan.george

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

4 years agoRevert "[DWARF] Support for loclist.dwo section in llvm and llvm-dwarfdump."
Sourabh Singh Tomar [Sat, 23 Nov 2019 14:14:42 +0000 (19:44 +0530)]
Revert "[DWARF] Support for loclist.dwo section in llvm and llvm-dwarfdump."

This reverts commit 81b0a3284af1dcef26e56b0de9fd74002083c471.
Will Re-apply, with updated Differtial Revision, for automatic closure of
Phabricator review.

4 years ago[RISCV] Add missing REQUIRES to clang tests
David Zarzycki [Sat, 23 Nov 2019 12:44:53 +0000 (14:44 +0200)]
[RISCV] Add missing REQUIRES to clang tests

Fixes: e0f22fe04a5c9eb244ff0533549743b7deb03b99

4 years ago[X86][SSE] Split off generic isLaneCrossingShuffleMask helper. NFC.
Simon Pilgrim [Sat, 23 Nov 2019 12:41:03 +0000 (12:41 +0000)]
[X86][SSE] Split off generic isLaneCrossingShuffleMask helper. NFC.

Avoid MVT dependency which will be needed in a future patch.

4 years ago[PhiValues] Remove redundant map searches
Ehud Katz [Tue, 5 Nov 2019 07:42:23 +0000 (09:42 +0200)]
[PhiValues] Remove redundant map searches

Remove redundant map searches.
For example, every call to "operator[]" is actually translated to a
"find" call, and 2 consecutive calls to the operator, without changing
the map in-between, is just redundant, and inefficient.

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

4 years ago[WebAssembly] Use wasm-opt and LTO libraries when available.
Dan Gohman [Wed, 20 Nov 2019 23:25:43 +0000 (15:25 -0800)]
[WebAssembly] Use wasm-opt and LTO libraries when available.

When there's a wasm-opt in the PATH, run the it to optimize LLVM's
output. This fixes PR43796.

And, add an "llvm-lto" directory to the sysroot library search paths,
so that sysroots can provide LTO-enabled system libraries.

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

4 years ago[DWARF] Support for loclist.dwo section in llvm and llvm-dwarfdump.
Sourabh Singh Tomar [Thu, 7 Nov 2019 06:57:46 +0000 (12:27 +0530)]
[DWARF] Support for loclist.dwo section in llvm and llvm-dwarfdump.

This patch adds support for debug_loclists.dwo section in llvm and llvm-dwarfdump.
Also Fixes PR43622, PR43623.

Reviewers: dblaikie, probinson, labath, aprantl, jini.susan.george

https://reviews.llvm.org/D69462

4 years ago[ASTMatchers] work around a miscompile; "NFC"
George Burgess IV [Sat, 23 Nov 2019 04:03:06 +0000 (20:03 -0800)]
[ASTMatchers] work around a miscompile; "NFC"

I chatted with Reid offline, and we agreed that having a workaround here
would be appropriate until PR43879 is resolved.

The given transformation Works On My Machine(TM), and should hopefully
hold more broadly, but my fingers are crossed nonetheless. :)

4 years ago[IR] Move global_objects and global_values out of line, NFC
Reid Kleckner [Sat, 23 Nov 2019 03:17:34 +0000 (19:17 -0800)]
[IR] Move global_objects and global_values out of line, NFC

This saves 2.4% of CPU time compiling opt, according to
ClangBuildAnalyzer. These helpers being inlined in the header was
triggering the instantiation of concat_iterator in every TU using
Module.h (~1118 TUs): https://reviews.llvm.org/P8171$35

**** Templates that took longest to instantiate:
 76187 ms: llvm::AnalysisManager<llvm::Function>::getResult<llvm::TargetLibrary... (396 times, avg 192 ms)
 73609 ms: llvm::AnalysisManager<llvm::Function>::getResultImpl (420 times, avg 175 ms)
 49657 ms: llvm::detail::concat_range<llvm::GlobalValue, llvm::iterator_range<l... (1118 times, avg 44 ms)
 49376 ms: llvm::detail::concat_range<const llvm::GlobalValue, llvm::iterator_r... (1118 times, avg 44 ms)
 48167 ms: llvm::iterator_range<llvm::concat_iterator<llvm::GlobalValue, llvm::... (1118 times, avg 43 ms)
 48125 ms: llvm::iterator_range<llvm::concat_iterator<const llvm::GlobalValue, ... (1118 times, avg 43 ms)
 48061 ms: llvm::concat_iterator<llvm::GlobalValue, llvm::ilist_iterator<llvm::... (1118 times, avg 42 ms)
 48014 ms: llvm::concat_iterator<const llvm::GlobalValue, llvm::ilist_iterator<... (1118 times, avg 42 ms)
...

I haven't measured, but I don't think these helpers are performance
critical.  The iterator advance call can still be inlined, which is what
matters for performance.

Remove global_(objects|values)_(begin|end), since they were dead and
would have to be out of line anyway.

4 years agoclang/Modules: Rename CompilerInstance::ModuleManager, NFC
Duncan P. N. Exon Smith [Fri, 22 Nov 2019 02:25:03 +0000 (18:25 -0800)]
clang/Modules: Rename CompilerInstance::ModuleManager, NFC

Fix the confusing naming of `CompilerInstance::ModuleManager`.  This is
actually an instance of `ASTReader`, which contains an instance of
`ModuleManager`.  I have to assume there was a point in the past where
they were just one class, but it's been pretty confusing for a while.  I
think it's time to fix it.

The new name is `TheASTReader`; the annoying `The` prefix is so that we
don't shadow the `ASTReader` class.  I tried out `ASTRdr` but that
seemed less clear, and this choice matches `ThePCHContainerOperations`
just a couple of declarations below.

Also rename `CompilerInstance::getModuleManager` and
`CompilerInstance::createModuleManager` to `*ASTReader`, making some
cases of `getModuleManager().getModuleManager()` a little more clear.

https://reviews.llvm.org/D70583

4 years agoclang/Modules: Refactor CompilerInstance::loadModule, NFC
Duncan P. N. Exon Smith [Thu, 21 Nov 2019 18:39:55 +0000 (10:39 -0800)]
clang/Modules: Refactor CompilerInstance::loadModule, NFC

Refactor the logic on CompilerInstance::loadModule and a couple of
surrounding methods in order to clarify what's going on.

- Rename ModuleLoader::loadModuleFromSource to compileModuleFromSource
  and fix its documentation, since it never loads a module.  It just
  creates/compiles one.
- Rename one of the overloads of compileModuleImpl to compileModule,
  making it more obvious which one calls the other.
- Rename compileAndLoadModule to compileModuleAndReadAST.  This
  clarifies the relationship between this helper and its caller,
  CompilerInstance::loadModule (the old name implied the opposite
  relationship).  It also (correctly) indicates that more needs to be
  done to load the module than this function is responsible for.
- Split findOrCompileModuleAndReadAST out of loadModule.  Besides
  reducing nesting for this code thanks to early returns and the like,
  this refactor clarifies the logic in loadModule, particularly around
  calls to ModuleMap::cacheModuleLoad and
  ModuleMap::getCachedModuleLoad.  findOrCompileModuleAndReadAST also
  breaks early if the initial ReadAST call returns Missing or OutOfDate,
  allowing the last ditch call to compileModuleAndReadAST to come at the
  end of the function body.
    - Additionally split out selectModuleSource, clarifying the logic
      due to early returns.
    - Add ModuleLoadResult::isNormal and OtherUncachedFailure, so that
      loadModule knows whether to cache the result.
      OtherUncachedFailure was added to keep this patch NFC, but there's
      a chance that these cases were uncached by accident, through
      copy/paste/modify failures.  These should be audited as a
      follow-up (maybe we can eliminate this case).
    - Do *not* lift the setting of `ModuleLoadFailed = true` to
      loadModule because there isn't a clear pattern for when it's set.
      This should be reconsidered in a follow-up, in case it would be
      correct to set `ModuleLoadFailed` whenever no module is returned
      and the result is either Normal or OtherUncachedFailure.
- Add some header documentation where it was missing, and fix it where
  it was wrong.

This should have no functionality change.

https://reviews.llvm.org/D70556

4 years agogn build: Reland c52efdc5, "gn build: (manually) merge b5913e6d2f"
Peter Collingbourne [Sat, 23 Nov 2019 02:05:19 +0000 (18:05 -0800)]
gn build: Reland c52efdc5, "gn build: (manually) merge b5913e6d2f"

Because b5913e6d2f landed again as c54959c0.

4 years agoclang-tidy: don't use an absolute path in a test
George Burgess IV [Sat, 23 Nov 2019 02:13:18 +0000 (18:13 -0800)]
clang-tidy: don't use an absolute path in a test

`run_clang_tidy` takes a regular expression to match against
compile_commands.json entries. If we pass "%t/test.cpp" and "%t" expands
to anything that includes chars that a regex treats specially, like '+',
this test starts failing.

4 years agoDebugInfo: Flag Dwarf Version metadata for merging during LTO
David Blaikie [Sat, 23 Nov 2019 01:01:54 +0000 (17:01 -0800)]
DebugInfo: Flag Dwarf Version metadata for merging during LTO

When the Dwarf Version metadata was initially added (r184276) there was
no support for Module::Max - though the comment suggested that was the
desired behavior. The original behavior was Module::Warn which would
warn and then pick whichever version came first - which is pretty
arbitrary/luck-based if the consumer has some need for one version or
the other.

Now that the functionality's been added (r303590) this change updates
the implementation to match the desired goal.

The general logic here is - if you compile /some/ of your program with a
more recent DWARF version, you must have a consumer that can handle it,
so might as well use it for /everything/.

The only place where this might fall down is if you have a need to use
an old tool (supporting only the older DWARF version) for some subset of
your program. In which case now it'll all be the higher version. That
seems pretty narrow (& the inverse could happen too - you specifically
/need/ the higher DWARF version for some extra expressivity, etc, in
some part of the program)

4 years agoRemove needless Attr.h include from DeclCXX.h, NFC
Reid Kleckner [Sat, 23 Nov 2019 00:14:40 +0000 (16:14 -0800)]
Remove needless Attr.h include from DeclCXX.h, NFC

This actually has no impact on the build, because TypeLoc.h includes
Attr.h. However, DeclCXX.h has no need of it, so go ahead and remove it.
The final step in this patch series is to split Attr.h and Attrs.h.

4 years agoSeparate the MS inheritance model enum from the attribute, NFC
Reid Kleckner [Sat, 16 Nov 2019 02:49:32 +0000 (18:49 -0800)]
Separate the MS inheritance model enum from the attribute, NFC

This avoids the need to include Attr.h in DeclCXX.h for a four-value
enum. Removing the include will be done separately, since it is large
and risky change.

4 years ago[Remarks] Allow empty temporary remark files
Francis Visoiu Mistrih [Fri, 22 Nov 2019 22:27:47 +0000 (14:27 -0800)]
[Remarks] Allow empty temporary remark files

When parsing bitstream remarks, allow external remark files to be
empty, which means there are no remarks to be parsed.

In the same way, dsymutil should not produce a remark file.

4 years agoMove vtordisp mode from Attr class to LangOptions.h, NFC
Reid Kleckner [Fri, 22 Nov 2019 22:55:49 +0000 (14:55 -0800)]
Move vtordisp mode from Attr class to LangOptions.h, NFC

This removes one of the two uses of Attr.h in DeclCXX.h, reducing the
need to include Attr.h as widely. LangOptions is already very popular.

4 years ago[Examples] Move structured-data unpacking out of the loop. (NFC)
Jonas Devlieghere [Fri, 22 Nov 2019 23:43:39 +0000 (15:43 -0800)]
[Examples] Move structured-data unpacking out of the loop. (NFC)

There's no need to repeat this work in the loop.

4 years ago[Examples] Add in_call_stack breakpoint function.
Jonas Devlieghere [Fri, 22 Nov 2019 23:32:43 +0000 (15:32 -0800)]
[Examples] Add in_call_stack breakpoint function.

The in_call_stack Python script makes it possible to modify the last
breakpoint to only stop if a given function is present in the call
stack. It will check both the symbol name and the function name (coming
from the debug info, in case the binary is stripped).

To use this, you have to:

1. Import the script into lldb.

(lldb) command script import in_call_stack.py

2. Set a breakpoint and use the in_call_stack alias.

(lldb) b foo
(lldb) in_call_stack bar

Note that this alias operates on the last set breakpoint. You can re-run
the in_call_stack command to modify the condition.

4 years ago[Driver] Make -static-libgcc imply static libunwind
Josh Kunz [Sat, 16 Nov 2019 01:53:55 +0000 (17:53 -0800)]
[Driver] Make -static-libgcc imply static libunwind

In the GNU toolchain, `-static-libgcc` implies that the unwindlib will
be linked statically. However, when `--unwindlib=libunwind`, this flag is
ignored, and a bare `-lunwind` is added to the linker args.  Unfortunately,
this means that if both `libunwind.so`, and `libunwind.a` are present
in the library path, `libunwind.so` will be chosen in all cases where
`-static` is not set.

This change makes `-static-libgcc` affect the `-l` flag produced by
`--unwindlib=libunwind`. After this patch, providing
`-static-libgcc --unwindlib=libunwind` will cause the driver to explicitly
emit `-l:libunwind.a` to statically link libunwind. For all other cases
it will emit `-l:libunwind.so` matching current behavior with a more
explicit link line.

https://reviews.llvm.org/D70416

4 years ago[MC] Reorder MCInst fields to make sizeof(MCInst) smaller
Fangrui Song [Fri, 22 Nov 2019 22:52:49 +0000 (14:52 -0800)]
[MC] Reorder MCInst fields to make sizeof(MCInst) smaller

sizeof(MCInst) is decreased from 168 to 160 on 64-bit systems.

4 years ago[MCA] Fix test cases (NFC)
Evandro Menezes [Mon, 23 Sep 2019 17:59:25 +0000 (12:59 -0500)]
[MCA] Fix test cases (NFC)

Fix the test cases for Exynos M5 that break under Darwin.

4 years agogn build: Merge 64ada7accbc
LLVM GN Syncbot [Fri, 22 Nov 2019 22:15:40 +0000 (22:15 +0000)]
gn build: Merge 64ada7accbc

4 years agoRemove extraneous log enabling.
Jason Molenda [Fri, 22 Nov 2019 22:13:35 +0000 (14:13 -0800)]
Remove extraneous log enabling.

4 years ago[TableGen] Add backend to generate command guide for tools using libOption.
Jonas Devlieghere [Fri, 22 Nov 2019 22:07:21 +0000 (14:07 -0800)]
[TableGen] Add backend to generate command guide for tools using libOption.

For lldb and dsymutil, the command guide is essentially a copy of its
help output generated by libOption. Making sure the two stay in sync is
tedious and error prone. Given that we already generate the help from a
tablegen file, we might as well generate the RST as well.

This adds a tablegen backend for generating Sphinx/RST command guides
from the tablegen file.

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

4 years agoReland "[CMake] Support installation of InstrProfData.inc"
Petr Hosek [Fri, 22 Nov 2019 20:09:15 +0000 (12:09 -0800)]
Reland "[CMake] Support installation of InstrProfData.inc"

This header fragment is useful on its own for any consumer that wants
to use custom instruction profile runtime with the LLVM instrumentation.
The concrete use case is in Fuchsia's kernel where we want to use
instruction profile instrumentation, but we cannot use the compiler-rt
runtime because it's not designed for use in the kernel environment.
This change allows installing this header as part of compiler-rt.

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

4 years agogn build: Merge ae8a8c2db6c
LLVM GN Syncbot [Fri, 22 Nov 2019 21:49:47 +0000 (21:49 +0000)]
gn build: Merge ae8a8c2db6c

4 years agoRevert "[Sema] Use the canonical type in function isVector"
Akira Hatanaka [Fri, 22 Nov 2019 21:48:39 +0000 (13:48 -0800)]
Revert "[Sema] Use the canonical type in function isVector"

This reverts commit a6150b48cea00ab31e9335cc73770327acc4cb3a.
The commit broke a few neon CodeGen tests.

4 years ago[Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy
Dávid Bolvanský [Fri, 22 Nov 2019 21:37:07 +0000 (22:37 +0100)]
[Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

Summary:
GCC 9 added -Wdeprecated-copy (as part of -Wextra). This diagnostic is already implemented in Clang too, just hidden under -Wdeprecated (not on by default).
This patch adds -Wdeprecated-copy and makes it compatible with GCC 9+.
This diagnostic is heavily tested in deprecated.cpp, so I added simple tests just to check we warn when new flag/-Wextra is enabled.

Reviewers: rsmith, dblaikie

Reviewed By: dblaikie

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[InstCombine] Fix call guard difference with dbg
Davide Italiano [Fri, 22 Nov 2019 21:02:18 +0000 (13:02 -0800)]
[InstCombine] Fix call guard difference with dbg

Patch by Chris Ye!

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

4 years ago[CodeMoverUtils] Added an API to check if an instruction can be safely
Tsang Whitney W.H [Fri, 22 Nov 2019 21:27:29 +0000 (21:27 +0000)]
[CodeMoverUtils] Added an API to check if an instruction can be safely
moved before another instruction.
Summary:Added an API to check if an instruction can be safely moved
before another instruction. In future PRs, we will like to add support
of moving instructions between blocks that are not control flow
equivalent, and add other APIs to enhance usability, e.g. moving basic
blocks, moving list of instructions...
Loop Fusion will be its first user. When there is intervening code in
between two loops, fusion is currently unable to fuse them. Loop Fusion
can use this utility to check if the intervening code can be safely
moved before or after the two loops, and move them, then it can
successfully fuse them.
Reviewer:kbarton,jdoerfert,Meinersbur,bmahjour,etiotto
Reviewed By:bmahjour
Subscribers:mgorny,hiraditya,llvm-commits
Tag:LLVM
Differential Revision:https://reviews.llvm.org/D70049

4 years ago[AArch64] Add the pipeline model for Exynos M5
Evandro Menezes [Mon, 23 Sep 2019 17:59:25 +0000 (12:59 -0500)]
[AArch64] Add the pipeline model for Exynos M5

Add the scheduling and cost models for Exynos M5.

4 years ago[libc] Add a TableGen based header generator.
Siva Chandra Reddy [Tue, 5 Nov 2019 19:40:26 +0000 (11:40 -0800)]
[libc] Add a TableGen based header generator.

Summary:
* The Python header generator has been removed.
* Docs giving a highlevel overview of the header gen scheme have been
  added.

Reviewers: phosek, abrachet

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Tags: #libc-project

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

4 years ago[Sema] Use the canonical type in function isVector
Akira Hatanaka [Fri, 22 Nov 2019 20:26:54 +0000 (12:26 -0800)]
[Sema] Use the canonical type in function isVector

This fixes an assertion in Sema::CreateBuiltinBinOp that fails when one
of the vector operand's element type is a typedef of __fp16.

rdar://problem/55983556

4 years agoFix typo to separate "-x" from warning flag.
Bill Wendling [Fri, 22 Nov 2019 20:51:41 +0000 (12:51 -0800)]
Fix typo to separate "-x" from warning flag.

4 years agoDon't report "main" as missing a prototype in freestanding mode
Bill Wendling [Fri, 22 Nov 2019 20:35:14 +0000 (12:35 -0800)]
Don't report "main" as missing a prototype in freestanding mode

Summary:
A user may want to use freestanding mode with the standard "main" entry
point. It's not useful to warn about a missing prototype as it's not
typical to have a prototype for "main".

Reviewers: efriedma, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Tags: #clang

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

4 years ago[OPENMP] [DOCS] correct status for use_device_addr clause
Kelvin Li [Fri, 22 Nov 2019 18:59:58 +0000 (13:59 -0500)]
[OPENMP] [DOCS] correct status for use_device_addr clause

The status of the use_device_addr clause feature is changed from 'done' to 'worked on`.

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

4 years ago[RISCV] Use compiler-rt if no GCC installation detected
Edward Jones [Fri, 22 Nov 2019 19:05:39 +0000 (19:05 +0000)]
[RISCV] Use compiler-rt if no GCC installation detected

If a GCC installation is not detected, then this attempts to
use compiler-rt and the compiler-rt crtbegin/crtend
implementations as a fallback.

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

4 years agoRevert "[CMake] Support installation of InstrProfData.inc"
Petr Hosek [Fri, 22 Nov 2019 20:00:23 +0000 (12:00 -0800)]
Revert "[CMake] Support installation of InstrProfData.inc"

This reverts commit f11bc1776fd2815b60e0b1ed97be00b517348162 since it's
failing to build on some bots.

4 years ago[CMake] Support installation of InstrProfData.inc
Petr Hosek [Fri, 22 Nov 2019 03:39:51 +0000 (19:39 -0800)]
[CMake] Support installation of InstrProfData.inc

This header fragment is useful on its own for any consumer that wants
to use custom instruction profile runtime with the LLVM instrumentation.
The concrete use case is in Fuchsia's kernel where we want to use
instruction profile instrumentation, but we cannot use the compiler-rt
runtime because it's not designed for use in the kernel environment.
This change allows installing this header as part of compiler-rt.

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

4 years ago[DWARF] Handle call sites with indirect call targets
Vedant Kumar [Sun, 15 Sep 2019 02:43:16 +0000 (19:43 -0700)]
[DWARF] Handle call sites with indirect call targets

Split CallEdge into DirectCallEdge and IndirectCallEdge. Teach
DWARFExpression how to evaluate entry values in cases where the current
activation was created by an indirect call.

rdar://57094085

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

4 years agoSlightly speculative buildbot fix for issue reported in 8293f74 commit thread
Philip Reames [Fri, 22 Nov 2019 19:37:04 +0000 (11:37 -0800)]
Slightly speculative buildbot fix for issue reported in 8293f74 commit thread

4 years ago[clang-include-fixer] Suppress cmd prompt from Vim on Windows
Reid Kleckner [Mon, 18 Nov 2019 23:15:10 +0000 (15:15 -0800)]
[clang-include-fixer] Suppress cmd prompt from Vim on Windows

Copied from the clang-format.py editor integration.

Reviewers: bkramer

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

4 years ago[APFloat] Enlarge ExponentType to 32bit integer
Ehud Katz [Sun, 3 Nov 2019 15:07:03 +0000 (17:07 +0200)]
[APFloat] Enlarge ExponentType to 32bit integer

Enlarge the size of ExponentType from 16bit integer to 32bit. This is
required to prevent exponent overflow/underflow.

Note that IEEEFloat size and alignment don't change in 64bit or 32bit
compilation targets (and in turn, neither does APFloat).

Fixes PR34851.

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

4 years agoReinstate MSan suppression of PR24578.
Evgenii Stepanov [Fri, 22 Nov 2019 18:58:26 +0000 (10:58 -0800)]
Reinstate MSan suppression of PR24578.

Summary:
Revert "Rollback of commit "Repress sanitization on User dtor.""

There is no point in keeping an active MSan error in the codebase.
PR24578 tracks the actual UB in LLVM code; this change enables testing
of LLVM with MSAN + -fsanitize-memory-use-after-dtor.

This reverts commit 21c1bc46aee2b69c2c48db8e961f0ce8394f21e1.

Reviewers: vitalybuka

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agoDon't forward __pthread_mutex_* interceptors to pthread_mutex_* version
Vitaly Buka [Fri, 22 Nov 2019 02:18:26 +0000 (18:18 -0800)]
Don't forward __pthread_mutex_* interceptors to pthread_mutex_* version

Summary:
Allows to use rr with asan

Fixes PR41095

Reviewers: eugenis

Subscribers: jfb, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[APFloat] Fix subtraction of subnormal numbers
Ehud Katz [Sun, 3 Nov 2019 15:28:54 +0000 (17:28 +0200)]
[APFloat] Fix subtraction of subnormal numbers

Fix incorrect determination of the bigger number out of the two
subtracted, while subnormal numbers are involved.
Fixes PR44010.

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

4 years ago[lit] Attempt to print test summary on CTRL+C
Julian Lettner [Tue, 26 Feb 2019 05:25:29 +0000 (21:25 -0800)]
[lit] Attempt to print test summary on CTRL+C

4 years ago[lldb][DataFormatters] Support pretty printing std::string when built with -funsigned...
Jordan Rupprecht [Fri, 22 Nov 2019 18:25:03 +0000 (10:25 -0800)]
[lldb][DataFormatters] Support pretty printing std::string when built with -funsigned-char.

Summary:
When built w/ `-funsigned-char`, `std::string` becomes equivalent to `std::basic_string<unsigned char>`, causing these formatters to not match. This patch adds overloads for both libstdc++ and libc++ string formatters that accepts unsigned char.

Motivated by the following example:

```
$ cat pretty_print.cc

template <typename T>
void print_val(T s) {
  std::cerr << s << '\n';  // Set a breakpoint here!
}

int main() {
  std::string val = "hello";
  print_val(val);
  return 0;
}
$ clang++ -stdlib=libc++ -funsigned-char -fstandalone-debug -g pretty_print.cc
$ lldb ./a.out -b -o 'b pretty_print.cc:6' -o r -o 'fr v'
...
(lldb) fr v
(std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >) s = {
  __r_ = {
    std::__1::__compressed_pair_elem<std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::__rep, 0, false> = {
      __value_ = {
         = {
          __l = (__cap_ = 122511465736202, __size_ = 0, __data_ = 0x0000000000000000)
          __s = {
             = (__size_ = '\n', __lx = '\n')
            __data_ = {
              [0] = 'h'
              [1] = 'e'
              [2] = 'l'
              [3] = 'l'
              [4] = 'o'
              [5] = '\0'
...
```

Reviewers: labath, JDevlieghere, shafik

Subscribers: christof, lldb-commits

Tags: #lldb

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

4 years agoReformat code for readability.
Adrian Prantl [Fri, 22 Nov 2019 18:03:25 +0000 (10:03 -0800)]
Reformat code for readability.

4 years agoComplete complete types early when importing types from Clang module DWARF.
Adrian Prantl [Fri, 22 Nov 2019 17:58:16 +0000 (09:58 -0800)]
Complete complete types early when importing types from Clang module DWARF.

This affects -gmodules only.

Under normal operation pcm_type is a shallow forward declaration
that gets completed later. This is necessary to support cyclic
data structures. If, however, pcm_type is already complete (for
example, because it was loaded for a different target before),
the definition needs to be imported right away, too.
Type::ResolveClangType() effectively ignores the ResolveState
inside type_sp and only looks at IsDefined(), so it never calls
ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(),
which does extra work for Objective-C classes. This would result
in only the forward declaration to be visible.

An alternative implementation would be to sink this into Type::ResolveClangType ( https://github.com/llvm/llvm-project/blob/88235812a71d99c082e7aa2ef9356d43d1f83a80/lldb/source/Symbol/Type.cpp#L5809) though it isn't clear to me how to best do this from a layering perspective.

rdar://problem/52134074

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

4 years agoRegister Objective-C property accessors with their property decls.
Adrian Prantl [Fri, 22 Nov 2019 01:21:49 +0000 (17:21 -0800)]
Register Objective-C property accessors with their property decls.

This is a correctness fix for the Clang DWARF parser that primarily
matters for swift-lldb's ability to import Clang types that were
reconstructed from DWARF into Swift.

rdar://problem/55025799

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

4 years ago[libTooling] Add stencil combinators for nodes that may be pointers or values.
Yitzhak Mandelbaum [Thu, 21 Nov 2019 19:35:22 +0000 (14:35 -0500)]
[libTooling] Add stencil combinators for nodes that may be pointers or values.

Summary:
Adds combinators `maybeDeref` and `maybeAddressOf` to provide a uniform way to handle
nodes which may be bound to either a pointer or a value (most often in the
context of member expressions). Such polymorphism is already supported by
`access`; these combinators extend it to more general uses.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[SLP] Enhance SLPVectorizer to vectorize vector aggregate
Anton Afanasyev [Mon, 11 Nov 2019 08:29:10 +0000 (11:29 +0300)]
[SLP] Enhance SLPVectorizer to vectorize vector aggregate

Summary:
Vector aggregate is homogeneous aggregate of vectors like `{ <2 x float>, <2 x float> }`.
This patch allows `findBuildAggregate()` to consider vector aggregates as
well as scalar ones. For instance, `{ <2 x float>, <2 x float> }` maps to `<4 x float>`.

Fixes vector part of llvm.org/PR42022

Reviewers: RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[WebAssembly][SelectionDAG] Remove unused WebAssemblyDAGToDAGISel::ForCodeSize.
Hiroshi Yamauchi [Thu, 21 Nov 2019 21:21:48 +0000 (13:21 -0800)]
[WebAssembly][SelectionDAG] Remove unused WebAssemblyDAGToDAGISel::ForCodeSize.

Summary:
This follows from the discussion at D70095.

D70095 moves hasOptSize calls into SelectionDAG::shouldOptForSize to allow
querying size optimization conditions together with profile guided size
optimization.

Since it appears that size optimizations for WebAssembly SelectionDAG haven't
been implemented yet and thus ForCodeSize is unused, and it would not make a lot
of sense to call shouldOptForSize here as the necessary profile data like
PSI/BFI aren't available at this point, it seems good and less confusing to
remove this for now and use shouldOptForSize when they are implemented in the
future.

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

Tags: #llvm

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

4 years ago[OPENMP]Simplify processing of context selectors, NFC.
Alexey Bataev [Fri, 22 Nov 2019 16:42:08 +0000 (11:42 -0500)]
[OPENMP]Simplify processing of context selectors, NFC.

4 years ago[JumpThreading] NFC: Don't cache F.hasProfileData()
Kazu Hirata [Fri, 22 Nov 2019 16:50:54 +0000 (08:50 -0800)]
[JumpThreading] NFC: Don't cache F.hasProfileData()

Summary:
With this patch, we no longer cache F.hasProfileData().  We simply
call the function again.

I'm doing this because:

- JumpThreadingPass also has a member variable named HasProfileData,
  which is very confusing,

- the function is very lightweight, and

- this patch makes JumpThreading::runOnFunction more consistent with
  JumpThreadingPass::run.

Subscribers: hiraditya, jfb, llvm-commits

Tags: #llvm

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

4 years ago[SLP][Test] Precommit tests for D70068 and D70587. NFC.
Anton Afanasyev [Thu, 21 Nov 2019 15:52:08 +0000 (18:52 +0300)]
[SLP][Test] Precommit tests for D70068 and D70587. NFC.

4 years ago[coroutines] Remove assert on CoroutineParameterMoves in Sema::buildCoroutineParamete...
Brian Gesiak [Fri, 22 Nov 2019 16:25:19 +0000 (11:25 -0500)]
[coroutines] Remove assert on CoroutineParameterMoves in Sema::buildCoroutineParameterMoves

Summary:
The assertion of CoroutineParameterMoves happens when build coroutine function with arguments  multiple time while fails to build promise type.

Fix: use return false instead.

Test Plan: check-clang

Reviewers: modocache, GorNishanov, rjmccall

Reviewed By: modocache

Subscribers: rjmccall, EricWF, cfe-commits

Tags: #clang

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

Patch by junparser (JunMa)!

4 years ago[OPENMP]Fix behaviour of defaultmap for OpenMP 4.5.
Alexey Bataev [Fri, 22 Nov 2019 16:09:33 +0000 (11:09 -0500)]
[OPENMP]Fix behaviour of defaultmap for OpenMP 4.5.

In OpenMP 4.5 pointers also must be considered as scalar types and
defaultmap(tofrom:scalar) clause must affect mapping of the pointers
too.

4 years ago[JumpThreading] Use profile data even with the new pass manager
Kazu Hirata [Fri, 22 Nov 2019 16:21:47 +0000 (08:21 -0800)]
[JumpThreading] Use profile data even with the new pass manager

Summary:
Without this patch, the jump threading pass ignores profiling data
whenever we invoke the pass with the new pass manager.

Specifically, JumpThreadingPass::run calls runImpl with class variable
HasProfileData always set to false.  In turn, runImpl sets
HasProfileData to false again:

  HasProfileData = HasProfileData_;

In the end, we don't use profiling data at all with the new pass
manager.

This patch fixes the problem by passing F.hasProfileData() to runImpl.

The bug appears to have been introduced at:

  https://reviews.llvm.org/D41461

which removed local variable HasProfileData in JumpThreadingPass::run
even though there was one more use left in the same function.  As a
result, the remaining use ended referring to the class variable
instead.

Note that F.hasProfileData is an extremely lightweight function, so I
don't see the need to cache its result.  Once this patch is approved,
I'm planning to stop caching the result of F.hasProfileData in
runOnFunction.

Reviewers: wmi, eli.friedman

Subscribers: hiraditya, jfb, llvm-commits

Tags: #llvm

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

4 years ago[OpenMP][Tool] archer tests require tsan
protze@itc.rwth-aachen.de [Fri, 22 Nov 2019 16:10:48 +0000 (17:10 +0100)]
[OpenMP][Tool] archer tests require tsan

Testing for tsan capability in the test-compiler in follow-up review

4 years ago[BPF] Fix a recursion bug in BPF Peephole ZEXT optimization
Yonghong Song [Fri, 22 Nov 2019 08:20:10 +0000 (00:20 -0800)]
[BPF] Fix a recursion bug in BPF Peephole ZEXT optimization

Commit a0841dfe8594 ("[BPF] Fix a bug in peephole optimization")
fixed a bug in peephole optimization. Recursion is introduced
to handle COPY and PHI instructions.

Unfortunately, multiple PHI instructions may form a cycle
and this will cause infinite recursion, eventual segfault.
For Commit a0841dfe8594, I indeed tried a few loops to ensure
that I won't see the recursion, but I did not try with
complex control flows, which, as demonstrated with the test case
in this patch, may introduce PHI cycles.

This patch fixed the issue by introducing a set to remember
visited PHI instructions. This way, cycles can be properly
detected and handled.

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

4 years ago[XCOFF][AIX] Read-only data section object file generation
jasonliu [Fri, 22 Nov 2019 15:36:46 +0000 (15:36 +0000)]
[XCOFF][AIX] Read-only data section object file generation

Summary:
This patch is a follow up on read-only assembly patch D70182.
It intends to enable object file generation for the read-only data section on AIX.

Reviewers: DiggerLin, daltenty

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

4 years agoAdd support to find out resource dir and add it as compilation args
Kousik Kumar [Sun, 3 Nov 2019 04:42:17 +0000 (21:42 -0700)]
Add support to find out resource dir and add it as compilation args

Summary:
If -resource-dir is not specified as part of the compilation command, then by default
clang-scan-deps picks up a directory relative to its own path as resource-directory.
This is probably not the right behavior - since resource directory should be picked relative
to the path of the clang-compiler in the compilation command.
This patch adds support for it along with a cache to store the resource-dir paths based on
compiler paths.

Notes:
1. "-resource-dir" is a behavior that's specific to clang, gcc does not have that flag. That's why if I'm not able to find a resource-dir, I quietly ignore it.
2. Should I also use the mtime of the compiler in the cache? I think its not strictly necessary since we assume the filesystem is immutable.
3. From my testing, this does not regress performance.
4. Will try to get this tested on Windows.

But basically the problem that this patch is trying to solve is, clients might not always want to specify
"-resource-dir" in their compile commands, so scan-deps must auto-infer it correctly.

Reviewers: arphaman, Bigcheese, jkorous, dexonsmith, klimek

Reviewed By: Bigcheese

Subscribers: MaskRay, cfe-commits

Tags: #clang

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

4 years ago[OpenMP][Tool] disable archer tests in standalone build
protze@itc.rwth-aachen.de [Fri, 22 Nov 2019 14:25:22 +0000 (15:25 +0100)]
[OpenMP][Tool] disable archer tests in standalone build

Will be enabled after Build-Bots are fixed

4 years agoReland "[DAGCombiner] Allow zextended load combines."
Clement Courbet [Fri, 22 Nov 2019 08:07:55 +0000 (09:07 +0100)]
Reland "[DAGCombiner] Allow zextended load combines."

Check that the generated type is simple.

4 years ago[Test] Fix freeze ocaml test failure
Juneyoung Lee [Fri, 22 Nov 2019 12:45:55 +0000 (21:45 +0900)]
[Test] Fix freeze ocaml test failure

4 years ago[OpenMP][Tool] Fix cmake variable in lit.site.cfg.in
protze@itc.rwth-aachen.de [Fri, 22 Nov 2019 13:29:19 +0000 (14:29 +0100)]
[OpenMP][Tool] Fix cmake variable in lit.site.cfg.in

As noted in D45890

4 years ago [WIP][Attributor] AAReachability Attribute
Pankaj Gode [Fri, 22 Nov 2019 13:10:47 +0000 (18:40 +0530)]
[WIP][Attributor] AAReachability Attribute

     Summary: Working towards Johannes's suggestion for fixme, in Attributor's Noalias attribute deduction.
(ii) Check whether the value is captured in the scope using AANoCapture.
FIXME: This is conservative though, it is better to look at CFG and
// check only uses possibly executed before this call site.

A Reachability abstract attribute answers the question "does execution at point A potentially reach point B". If this question is answered with false for all other uses of the value that might be captured, we know it is not *yet* captured and can continue with the noalias deduction. Currently, information AAReachability provides is completely pessimistic.

    Reviewers: jdoerfert

    Reviewed By: jdoerfert

    Subscribers: uenoku, sstefan1, hiraditya, llvm-commits

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

4 years ago[Codegen] TargetLowering::prepareUREMEqFold(): `x u% C1 ==/!= C2` (PR35479)
Roman Lebedev [Fri, 22 Nov 2019 12:22:42 +0000 (15:22 +0300)]
[Codegen] TargetLowering::prepareUREMEqFold(): `x u% C1 ==/!= C2` (PR35479)

Summary:
The current lowering is:
```
Name: (X % C1) == C2 -> X * C3 <= C4 || false
Pre: (C2 == 0 || C1 u<= C2) && (C1 u>> countTrailingZeros(C1)) * C3 == 1
%zz = and i8 C3, 0 ; trick alive into making C3 avaliable in precondition
%o0 = urem i8 %x, C1
%r = icmp eq i8 %o0, C2
  =>
%zz = and i8 C3, 0 ; and silence it from complaining about said reg
%C4 = -1 /u C1
%n0 = mul i8 %x, C3
%n1 = lshr i8 %n0, countTrailingZeros(C1) ; rotate right
%n2 = shl i8 %n0, ((8-countTrailingZeros(C1)) %u 8) ; rotate right
%n3 = or i8 %n1, %n2 ; rotate right
%is_tautologically_false = icmp ule i8 C1, C2
%C4_fixed = select i1 %is_tautologically_false, i8 -1, i8 %C4
%res = icmp ule i8 %n3, %C4_fixed
%r = xor i1 %res, %is_tautologically_false
```
https://rise4fun.com/Alive/2xC
https://rise4fun.com/Alive/jpb5

However, we can support non-tautological cases `C1 u> C2` too.
Said handling consists of two parts:
* `C2 u<= (-1 %u C1)`. It just works. We only have to change `(X % C1) == C2` into `((X - C2) % C1) == 0`
```
Name: (X % C1) == C2 -> (X - C2) * C3 <= C4   iff C2 u<= (-1 %u C1)
Pre: (C1 u>> countTrailingZeros(C1)) * C3 == 1 && C2 u<= (-1 %u C1)
%zz = and i8 C3, 0 ; trick alive into making C3 avaliable in precondition
%o0 = urem i8 %x, C1
%r = icmp eq i8 %o0, C2
  =>
%zz = and i8 C3, 0 ; and silence it from complaining about said reg
%C4 = (-1 /u C1)
%n0 = sub i8 %x, C2
%n1 = mul i8 %n0, C3
%n2 = lshr i8 %n1, countTrailingZeros(C1) ; rotate right
%n3 = shl i8 %n1, ((8-countTrailingZeros(C1)) %u 8) ; rotate right
%n4 = or i8 %n2, %n3 ; rotate right
%is_tautologically_false = icmp ule i8 C1, C2
%C4_fixed = select i1 %is_tautologically_false, i8 -1, i8 %C4
%res = icmp ule i8 %n4, %C4_fixed
%r = xor i1 %res, %is_tautologically_false
```
https://rise4fun.com/Alive/m4P
https://rise4fun.com/Alive/SKrx
* `C2 u> (-1 %u C1)`. We also have to change `(X % C1) == C2` into `((X - C2) % C1) == 0`,
  and we have to decrement C4:
```
Name: (X % C1) == C2 -> (X - C2) * C3 <= C4   iff C2 u> (-1 %u C1)
Pre: (C1 u>> countTrailingZeros(C1)) * C3 == 1 && C2 u> (-1 %u C1)
%zz = and i8 C3, 0 ; trick alive into making C3 avaliable in precondition
%o0 = urem i8 %x, C1
%r = icmp eq i8 %o0, C2
  =>
%zz = and i8 C3, 0 ; and silence it from complaining about said reg
%C4 = (-1 /u C1)-1
%n0 = sub i8 %x, C2
%n1 = mul i8 %n0, C3
%n2 = lshr i8 %n1, countTrailingZeros(C1) ; rotate right
%n3 = shl i8 %n1, ((8-countTrailingZeros(C1)) %u 8) ; rotate right
%n4 = or i8 %n2, %n3 ; rotate right
%is_tautologically_false = icmp ule i8 C1, C2
%C4_fixed = select i1 %is_tautologically_false, i8 -1, i8 %C4
%res = icmp ule i8 %n4, %C4_fixed
%r = xor i1 %res, %is_tautologically_false
```
https://rise4fun.com/Alive/d40
https://rise4fun.com/Alive/8cF

I believe this concludes `x u% C1 ==/!= C2` lowering.
In fact, clang is may now be better in this regard than gcc:
as it can be seen from `@t32_6_4` test, we do lower `x % 6 == 4`
via this pattern, while gcc does not: https://godbolt.org/z/XNU2z9
And all the general alive proofs say this is legal.
And manual checking agrees: https://rise4fun.com/Alive/WA2

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

Reviewers: RKSimon, craig.topper, spatel

Reviewed By: RKSimon

Subscribers: nick, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[Codegen] TargetLowering::prepareUREMEqFold(): `x u% C1 ==/!= C2` with tautological...
Roman Lebedev [Fri, 22 Nov 2019 12:16:03 +0000 (15:16 +0300)]
[Codegen] TargetLowering::prepareUREMEqFold(): `x u% C1 ==/!= C2` with tautological C1 u<= C2 (PR35479)

Summary:
This is a preparatory cleanup before i add more
of this fold to deal with comparisons with non-zero.

In essence, the current lowering is:
```
Name: (X % C1) == 0 -> X * C3 <= C4
Pre: (C1 u>> countTrailingZeros(C1)) * C3 == 1
%zz = and i8 C3, 0 ; trick alive into making C3 avaliable in precondition
%o0 = urem i8 %x, C1
%r = icmp eq i8 %o0, 0
  =>
%zz = and i8 C3, 0 ; and silence it from complaining about said reg
%C4 = -1 /u C1
%n0 = mul i8 %x, C3
%n1 = lshr i8 %n0, countTrailingZeros(C1) ; rotate right
%n2 = shl i8 %n0, ((8-countTrailingZeros(C1)) %u 8) ; rotate right
%n3 = or i8 %n1, %n2 ; rotate right
%r = icmp ule i8 %n3, %C4
```
https://rise4fun.com/Alive/oqd

It kinda just works, really no weird edge-cases.
But it isn't all that great for when comparing with non-zero.
In particular, given `(X % C1) == C2`, there will be problems
in the always-false tautological case where `C2 u>= C1`:
https://rise4fun.com/Alive/pH3

That case is tautological, always-false:
```
Name: (X % Y) u>= Y
%o0 = urem i8 %x, %y
%r = icmp uge i8 %o0, %y
  =>
%r = false
```
https://rise4fun.com/Alive/ofu

While we can't/shouldn't get such tautological case normally,
we do deal with non-splat vectors, so unless we want to give up
in this case, we need to fixup/short-circuit such lanes.

There are two lowering variants:
1. We can blend between whatever computed result and the correct tautological result
```
Name: (X % C1) == C2 -> X * C3 <= C4 || false
Pre: (C2 == 0 || C1 u<= C2) && (C1 u>> countTrailingZeros(C1)) * C3 == 1
%zz = and i8 C3, 0 ; trick alive into making C3 avaliable in precondition
%o0 = urem i8 %x, C1
%r = icmp eq i8 %o0, C2
  =>
%zz = and i8 C3, 0 ; and silence it from complaining about said reg
%C4 = -1 /u C1
%n0 = mul i8 %x, C3
%n1 = lshr i8 %n0, countTrailingZeros(C1) ; rotate right
%n2 = shl i8 %n0, ((8-countTrailingZeros(C1)) %u 8) ; rotate right
%n3 = or i8 %n1, %n2 ; rotate right
%is_tautologically_false = icmp ule i8 C1, C2
%res = icmp ule i8 %n3, %C4
%r = select i1 %is_tautologically_false, i1 0, i1 %res
```
https://rise4fun.com/Alive/PjT5
https://rise4fun.com/Alive/1KV

2. We can invert the comparison result
```
Name: (X % C1) == C2 -> X * C3 <= C4 || false
Pre: (C2 == 0 || C1 u<= C2) && (C1 u>> countTrailingZeros(C1)) * C3 == 1
%zz = and i8 C3, 0 ; trick alive into making C3 avaliable in precondition
%o0 = urem i8 %x, C1
%r = icmp eq i8 %o0, C2
  =>
%zz = and i8 C3, 0 ; and silence it from complaining about said reg
%C4 = -1 /u C1
%n0 = mul i8 %x, C3
%n1 = lshr i8 %n0, countTrailingZeros(C1) ; rotate right
%n2 = shl i8 %n0, ((8-countTrailingZeros(C1)) %u 8) ; rotate right
%n3 = or i8 %n1, %n2 ; rotate right
%is_tautologically_false = icmp ule i8 C1, C2
%C4_fixed = select i1 %is_tautologically_false, i8 -1, i8 %C4
%res = icmp ule i8 %n3, %C4_fixed
%r = xor i1 %res, %is_tautologically_false
```
https://rise4fun.com/Alive/2xC
https://rise4fun.com/Alive/jpb5

3. We can expand into `and`/`or`:
https://rise4fun.com/Alive/WGn
https://rise4fun.com/Alive/lcb5

Blend-one is likely better since we avoid having to load the
replacement from constant pool. `xor` is second best since
it's still pretty general. I'm not adding `and`/`or` variants.

Reviewers: RKSimon, craig.topper, spatel

Reviewed By: RKSimon

Subscribers: nick, hiraditya, xbolva00, llvm-commits

Tags: #llvm

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

4 years ago[lldb] [test] XFAIL TestExpressionEvaluation on NetBSD
Michał Górny [Fri, 22 Nov 2019 12:03:16 +0000 (13:03 +0100)]
[lldb] [test] XFAIL TestExpressionEvaluation on NetBSD

4 years ago[X86] Updated strict fp scalar tests and add fp80 tests for D68857
Simon Pilgrim [Fri, 22 Nov 2019 11:57:08 +0000 (11:57 +0000)]
[X86] Updated strict fp scalar tests and add fp80 tests for D68857

4 years ago[clangd] Show lambda signature for lambda autocompletions
Kirill Bobyrev [Fri, 22 Nov 2019 11:48:06 +0000 (12:48 +0100)]
[clangd] Show lambda signature for lambda autocompletions

The original bug report can be found
[here](https://github.com/clangd/clangd/issues/85)

Given the following code:

```c++
void function() {
  auto Lambda = [](int a, double &b) {return 1.f;};
  La^
}
```

Triggering the completion at `^` would show `(lambda)` before this patch
and would show signature `(int a, double &b) const`, build a snippet etc
with this patch.

Reviewers: sammccall

Reviewed by: sammccall

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

4 years ago[lldb] Fix exception breakpoint not being resolved when set on dummy target
Martin Svensson [Fri, 22 Nov 2019 10:18:47 +0000 (11:18 +0100)]
[lldb] Fix exception breakpoint not being resolved when set on dummy target

Summary: Ensure that breakpoint ivar is properly set in exception breakpoint resolver so that exception breakpoints set on dummy targets are resolved once real targets are created and run.

Reviewers: jingham

Reviewed By: jingham

Subscribers: teemperor, JDevlieghere, lldb-commits

Tags: #lldb

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

4 years agoTest commit.
Pankaj Gode [Fri, 22 Nov 2019 09:16:43 +0000 (14:46 +0530)]
Test commit.

4 years ago[DWARFVerifier] Use the new location list api
Pavel Labath [Fri, 8 Nov 2019 14:33:54 +0000 (15:33 +0100)]
[DWARFVerifier] Use the new location list api

Summary:
Instead of going to the debug_loc section directly, use new
DWARFDie::getLocations instead. This means that the code will now
automatically support debug_loclists sections.

This is the last usage of the old debug_loc methods, and they can now be
removed.

Reviewers: dblaikie, JDevlieghere, aprantl, SouraVX

Subscribers: hiraditya, probinson, llvm-commits

Tags: #llvm

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

4 years ago[PowerPC] Implement the vector extend sign instruction pattern match
QingShan Zhang [Fri, 22 Nov 2019 08:55:13 +0000 (08:55 +0000)]
[PowerPC] Implement the vector extend sign instruction pattern match
Power9 has instructions to implement the semantics of SIGN_EXTEND_INREG for vector type.
Mark it as legal and add the match pattern.

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

4 years agogn build: Merge f7170d17a84
LLVM GN Syncbot [Fri, 22 Nov 2019 08:12:49 +0000 (08:12 +0000)]
gn build: Merge f7170d17a84

4 years agogn build: Merge aa981c1802d
LLVM GN Syncbot [Fri, 22 Nov 2019 08:12:48 +0000 (08:12 +0000)]
gn build: Merge aa981c1802d

4 years agogn build: Merge 95fe54931fd
LLVM GN Syncbot [Fri, 22 Nov 2019 08:12:48 +0000 (08:12 +0000)]
gn build: Merge 95fe54931fd

4 years agogn build: (manually) merge dep from f65cfff6
Nico Weber [Fri, 22 Nov 2019 08:12:25 +0000 (03:12 -0500)]
gn build: (manually) merge dep from f65cfff6

4 years agoRevert "[DAGCombiner] Allow zextended load combines."
Clement Courbet [Fri, 22 Nov 2019 08:00:16 +0000 (09:00 +0100)]
Revert "[DAGCombiner] Allow zextended load combines."

Breaks some bots.

4 years ago[clang-tidy] new performance-no-automatic-move check.
Clement Courbet [Mon, 18 Nov 2019 12:22:10 +0000 (13:22 +0100)]
[clang-tidy] new performance-no-automatic-move check.

Summary: The check flags constructs that prevent automatic move of local variables.

Reviewers: aaron.ballman

Subscribers: mgorny, xazax.hun, cfe-commits

Tags: #clang

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

4 years ago[DAGCombiner] Allow zextended load combines.
Clement Courbet [Tue, 19 Nov 2019 15:24:43 +0000 (16:24 +0100)]
[DAGCombiner] Allow zextended load combines.

Summary: or(zext(load8(base)), zext(load8(base+1)) -> zext(load16 base)

Reviewers: apilipenko, RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[lldb] Don't enable expression log in TestEmptyStdModule.py
Raphael Isemann [Fri, 22 Nov 2019 07:34:04 +0000 (08:34 +0100)]
[lldb] Don't enable expression log in TestEmptyStdModule.py

Thanks for pointing this out Jason!

4 years ago[CFG] Fix a flaky crash in CFGBlock::getLastCondition().
Artem Dergachev [Fri, 22 Nov 2019 05:53:50 +0000 (21:53 -0800)]
[CFG] Fix a flaky crash in CFGBlock::getLastCondition().

Using an end iterator of an empty CFG block was causing
a garbage pointer dereference.

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

4 years ago[CMake] Fix LLVM build non-determinism on RHEL
Amy Kwan [Fri, 22 Nov 2019 05:06:33 +0000 (23:06 -0600)]
[CMake] Fix LLVM build non-determinism on RHEL

On RHEL, the OS tooling (ar, ranlib) is not deterministic by default.
Therefore, we cannot get bit-for-bit identical builds.

The goal of this patch is that it adds the flags required to force determinism.

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

4 years ago[PowerPC] combine rlwinm+rlwinm to rlwinm
czhengsz [Fri, 22 Nov 2019 05:00:33 +0000 (00:00 -0500)]
[PowerPC] combine rlwinm+rlwinm to rlwinm
combine
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12

to
x3 = rlwinm x3, 14, 0, 12

Reviewed by: steven.zhang

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

4 years ago[X86] Add option 'disable-strictnode-mutation' for tests that respect
Wang, Pengfei [Fri, 22 Nov 2019 04:24:38 +0000 (12:24 +0800)]
[X86] Add option 'disable-strictnode-mutation' for tests that respect
strict fp semantics. NFCI.

4 years ago[RISCV] Support mutilib in baremetal environment
Zakk Chen [Thu, 21 Nov 2019 09:12:48 +0000 (01:12 -0800)]
[RISCV] Support mutilib in baremetal environment

1. Currently only support the set of multilibs same to riscv-gnu-toolchain.
2. Fix testcase typo causes fail on Windows.
3. Fix testcases to set empty sysroot.

Reviewers: espindola, asb, kito-cheng, lenary

Reviewed By: lenary

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