lldb.git
2 years ago[SEH] Defer checking filter expression types until instantiaton
Reid Kleckner [Thu, 7 Nov 2019 22:13:26 +0000 (14:13 -0800)]
[SEH] Defer checking filter expression types until instantiaton

While here, wordsmith the error a bit. Now clang says:
  error: filter expression has non-integral type 'Foo'

Fixes PR43779

Reviewers: amccarth

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

2 years agoCorrectly update isSignalFrame when unwinding the stack via dwarf.
Sterling Augustine [Thu, 31 Oct 2019 19:45:20 +0000 (12:45 -0700)]
Correctly update isSignalFrame when unwinding the stack via dwarf.

A "signal frame" is a function or block of code where execution arrives via a signal or interrupt, rather than via a normal call instruction. In fact, a particular instruction is interrupted by the signal and needs to be restarted. Therefore, when the signal handler is complete, execution needs to return to the interrupted instruction, rather than the instruction immediately following the call instruction, as in a normal call.

Stack unwinders need to know this to correctly unwind signal frames. Dwarf handily provides an "S" in the CIE augmentation string to describe this case, and the libunwind API provides various functions to for unwinders to determine it,.

The llvm libunwind implementation correctly sets it's internal variable "isSignalFrame" when initializing an unwind context. However, upon stepping up the stack, the current implementation correctly reads the augmentation string and sets it in the CIE info (which it then discards), libunwind doesn't update it's internal unwind context data structure.

This change fixes that, and provides compatibility with both the canonical libunwind and the libgcc implementation.

Reviewers: jfb

Subscribers: christof, libcxx-commits

Tags: #libc

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

2 years agogn build: Merge 25ee861372f
LLVM GN Syncbot [Thu, 7 Nov 2019 22:43:50 +0000 (22:43 +0000)]
gn build: Merge 25ee861372f

2 years ago[debugify] Move the Debugify pass from tools/opt to lib/Transform/Utils
Daniel Sanders [Thu, 7 Nov 2019 00:08:01 +0000 (16:08 -0800)]
[debugify] Move the Debugify pass from tools/opt to lib/Transform/Utils

Summary:
I need to make use of this pass from a driver program that isn't opt.
Therefore this patch moves this pass into the LLVM library so that it is
available for use elsewhere.

There was one function I kept in tools/opt which is exportDebugifyStats()
this is because it's serializing the statistics into a human readable
format and this seemed more in keeping with opt than a library function

Reviewers: vsk, aprantl

Subscribers: mgorny, hiraditya, llvm-commits

Tags: #llvm

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

2 years ago[compiler-rt] Fix tests after 03b84e4f6d0
Jan Korous [Thu, 7 Nov 2019 22:40:22 +0000 (14:40 -0800)]
[compiler-rt] Fix tests after 03b84e4f6d0

Fallout from:
[clang] Report sanitizer blacklist as a dependency in cc1

Default blacklists are now passed via -fsanitize-system-blacklist from driver to cc1.

2 years agoBreakpointDummyOptionGroup was using g_breakpoint_modify_options rather than g_breakp...
Jim Ingham [Thu, 7 Nov 2019 20:44:03 +0000 (12:44 -0800)]
BreakpointDummyOptionGroup was using g_breakpoint_modify_options rather than g_breakpoint_dummy_options
causing the -D option for breakpoint set command to be incorrectly parsed.

Patch by Martin Svensson.

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

2 years ago[clang] Report sanitizer blacklist as a dependency in cc1
Jan Korous [Thu, 7 Nov 2019 21:56:14 +0000 (13:56 -0800)]
[clang] Report sanitizer blacklist as a dependency in cc1

Previously these were reported from the driver which blocked clang-scan-deps from getting the full set of dependencies from cc1 commands.

Also the default sanitizer blacklist that is added in driver was never reported as a dependency. I introduced -fsanitize-system-blacklist cc1 option to keep track of which blacklists were user-specified and which were added by driver and clang -MD now also reports system blacklists as dependencies.

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

2 years agoRevert "[MachineVerifier] Improve verification of live-in lists.
Galina Kistanova [Thu, 7 Nov 2019 22:02:13 +0000 (14:02 -0800)]
Revert "[MachineVerifier] Improve verification of live-in lists.

This reverts commit b7b170c to give the author more time to address failing tests on the expensive checks buildbots.

2 years ago[codeview] Reference types in type parent scopes
Reid Kleckner [Wed, 6 Nov 2019 23:04:52 +0000 (15:04 -0800)]
[codeview] Reference types in type parent scopes

Without this change, when a nested tag type of any kind (enum, class,
struct, union) is used as a variable type, it is emitted without
emitting the parent type. In CodeView, parent types point to their inner
types, and inner types do not point back to their parents. We already
walk over all of the parent scopes to build the fully qualified name.
This change simply requests their type indices as we go along to enusre
they are all emitted.

Fixes PR43905

Reviewers: akhuang, amccarth

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

2 years ago[Diagnostics] Teach -Wnull-dereference about address_space attribute
Dávid Bolvanský [Thu, 7 Nov 2019 19:47:09 +0000 (20:47 +0100)]
[Diagnostics] Teach -Wnull-dereference about address_space attribute

Summary:
Clang should not warn for:

> test.c:2:12: warning: indirection of non-volatile null pointer will be deleted,
>       not trap [-Wnull-dereference]
>     return *(int __attribute__((address_space(256))) *) 0;
>            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Solves PR42292.

Reviewers: aaron.ballman, rsmith

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

2 years ago[CodeGenModule] Group blocks runtime globals together, NFC
Vedant Kumar [Thu, 7 Nov 2019 20:46:26 +0000 (12:46 -0800)]
[CodeGenModule] Group blocks runtime globals together, NFC

2 years ago[lldb] Improve assert in GDBRemoteCommunicationReplayServer
Jonas Devlieghere [Thu, 7 Nov 2019 19:13:47 +0000 (11:13 -0800)]
[lldb] Improve assert in GDBRemoteCommunicationReplayServer

While investigating an issue where a different packet was sent during
replay I noticed how annoying it is that the existing assert doesn't
specify what packet is actually different. It's printed to the log, but
enabling logging has the potential to change LLDB's behavior. The same
is true when debugging LLDB while it's replaying the reproducer.

I replaced the assert with a printf of the unexpected packet followed by
a fatal_error wrapped in ifndef NDEBUG. The behavior is the same as the
previous assert, just with more/better context.

2 years ago[InstCombine] Add test cases to show bad canonicalization of bitcasts between x86_mmx...
Craig Topper [Thu, 7 Nov 2019 20:37:24 +0000 (12:37 -0800)]
[InstCombine] Add test cases to show bad canonicalization of bitcasts between x86_mmx and <1 x i64>.

As the test cases show, we end up with an insert/extract and a
bitcast to/from i64. x86_mmx is for some purposes conceptually a
vector. We shouldn't be adding scalar conversions around it.

Since _m64 is defined as <1 x i64> and intrinsics use x86_mmx
as their input/output these extra scalar operations prevent
the X86 backend from generating good code especially on 32-bit
targets where i64 gets split.

2 years ago[Sema] Fixes a crash with a templated destructor
Mark de Wever [Thu, 7 Nov 2019 20:22:03 +0000 (21:22 +0100)]
[Sema] Fixes a crash with a templated destructor

The issue was introduced by D33189 which fixed PR33189.

Fixes PR38671: "destructor cannot be declared as a template" leads to segfault in Sema::LookupSpecialMember

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

2 years ago[clang] Add -fdebug-default-version for specifying the default DWARF version
David Blaikie [Thu, 7 Nov 2019 20:00:22 +0000 (12:00 -0800)]
[clang] Add -fdebug-default-version for specifying the default DWARF version

This flag decouples specifying the DWARF version from enabling/disabling
DWARF in general (or the gN level - gmlt/limited/standalone, etc) while
still allowing existing -gdwarf-N flags to override this default.

Patch by Caroline Tice!

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

2 years agoWrong debug info generated at -O2 (-O0 is correct)
Vedant Kumar [Thu, 7 Nov 2019 19:19:41 +0000 (11:19 -0800)]
Wrong debug info generated at -O2 (-O0 is correct)

Instcombiner pass was erasing trivially dead instruction without updating dependent llvm.dbg.value.
which was not showing programmer current state of variables while debugging.
As a part of this fix I did following,
Iterate throught all the users (llvm.dbg) of a instruction which is trivially dead and set each if them undef, Before deleting the instruction.
Now user will see optimized out, when try to print those variables.
This fixes
https://bugs.llvm.org/show_bug.cgi?id=43893

This is my first fix to llvm.

Patch by kamlesh kumar!

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

2 years agocrashlog.py: Improve regular expressions
Adrian Prantl [Thu, 7 Nov 2019 18:50:37 +0000 (10:50 -0800)]
crashlog.py: Improve regular expressions

This is yet another change to the regular expressions in crashlog.py
that fix a few edge cases, and attempt to improve the readability
quite a bit in the process. My last change to support spaces in
filenames introduced a bug that caused the version/archspec field to
be parsed as part of the image name.

For example, in "0x1111111 - 0x22222 +MyApp Pro arm64 <01234>", the
name of the image was recognized as "MyApp Pro arm64" instead of
"MyApp Pro" with a "version" of arm64.

The bugfix makes the space following an optional field mandatory
*inside* the optional group.

rdar://problem/56883435

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

2 years agoRevert "[Sema] Suppress -Wchar-subscripts if the index is a literal char"
Edward Jones [Thu, 7 Nov 2019 18:19:09 +0000 (18:19 +0000)]
Revert "[Sema] Suppress -Wchar-subscripts if the index is a literal char"

This reverts commit 7adab7719e55e1b29bfd521dcc73f202139e8f41.

2 years agoFDRRecords - fix uninitialized variable warnings. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 18:41:49 +0000 (18:41 +0000)]
FDRRecords - fix uninitialized variable warnings. NFCI.

2 years agoImutAVLTree::validateTree - fix null dereference typo warning. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 18:41:01 +0000 (18:41 +0000)]
ImutAVLTree::validateTree - fix null dereference typo warning. NFCI.

Noticed by static analyzer.

2 years agocanFoldMergeOpcode returns a bool result not an unsigned. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 18:00:43 +0000 (18:00 +0000)]
canFoldMergeOpcode returns a bool result not an unsigned. NFCI.

2 years agoFix warning about unused std::unique result, erase shifted elements
Reid Kleckner [Thu, 7 Nov 2019 18:37:04 +0000 (10:37 -0800)]
Fix warning about unused std::unique result, erase shifted elements

This is actually a functional change. I haven't added any new test
coverage. I'm just trying to fix the warning and hoping for the best.

2 years ago[AsmWritter] Fixed "null check after dereferencing" warning
Dávid Bolvanský [Wed, 6 Nov 2019 18:20:48 +0000 (19:20 +0100)]
[AsmWritter] Fixed "null check after dereferencing" warning

Summary: The 'BB->getParent()' pointer was utilized before it was verified against nullptr. Check lines: 3567, 3581.

Reviewers: jyknight, RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

2 years ago[RISCV] Fix up tests on Windows after new usage of sys::path::append
Reid Kleckner [Thu, 7 Nov 2019 17:53:56 +0000 (09:53 -0800)]
[RISCV] Fix up tests on Windows after new usage of sys::path::append

2 years ago[XCOFF] Add back extern template declarations
Reid Kleckner [Thu, 7 Nov 2019 17:42:25 +0000 (09:42 -0800)]
[XCOFF] Add back extern template declarations

The extern template declarations were fine. The duplicate explicit
instantiations were both in the .cpp file.

2 years agoRevert "[XCOFF] Fix link errors from explicit template instantiation"
Reid Kleckner [Thu, 7 Nov 2019 17:39:13 +0000 (09:39 -0800)]
Revert "[XCOFF] Fix link errors from explicit template instantiation"

This reverts commit c989993ba1a666f04f7aee7df51d9f4de0588b71.

maskray already fixed the explicit instantiation definition in the .cpp
file, and these extern template declarations seem to be causing
warnings that I don't understand.

2 years ago[XCOFF] Fix link errors from explicit template instantiation
Reid Kleckner [Thu, 7 Nov 2019 17:27:43 +0000 (09:27 -0800)]
[XCOFF] Fix link errors from explicit template instantiation

I happen to be using clang-cl+lld-link locally, and I get these link
errors:

lld-link: error: undefined symbol: public: unsigned short __cdecl llvm::object::XCOFFSectionHeader<struct llvm::object::XCOFFSectionHeader64>::getSectionType(void) const
>>> referenced by C:\src\llvm-project\llvm\tools\llvm-readobj\XCOFFDumper.cpp:106
>>>               tools\llvm-readobj\CMakeFiles\llvm-readobj.dir\XCOFFDumper.cpp.obj:(public: virtual void __cdecl `anonymous namespace'::XCOFFDumper::printSectionHeaders(void))

I suspect this is because the explicit template instaniation appears
before the inline method definitions in the .cpp file, so they aren't
available at the point of instantiation. Move the explicit instantiation
later.

Also, forward declare the explicit instantiation for good measure.

2 years ago[llvm-ar] Support verbose mode for operation 'x'
Fangrui Song [Wed, 6 Nov 2019 18:19:30 +0000 (10:19 -0800)]
[llvm-ar] Support verbose mode for operation 'x'

Reviewed By: jhenderson, kongyi

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

2 years ago[XCOFF] Move explicit instantions after member function definitions to fix clang...
Fangrui Song [Thu, 7 Nov 2019 17:25:31 +0000 (09:25 -0800)]
[XCOFF] Move explicit instantions after member function definitions to fix clang builds

2 years ago[InstCombine] canonicalize shift+logic+shift to reduce dependency chain
Sanjay Patel [Thu, 7 Nov 2019 17:08:10 +0000 (12:08 -0500)]
[InstCombine] canonicalize shift+logic+shift to reduce dependency chain

shift (logic (shift X, C0), Y), C1 --> logic (shift X, C0+C1), (shift Y, C1)

This is an IR translation of an existing SDAG transform added here:
rL370617

So we again have 9 possible patterns with a commuted IR variant of each pattern:
https://rise4fun.com/Alive/VlI
https://rise4fun.com/Alive/n1m
https://rise4fun.com/Alive/1Vn

Part of the motivation is to allow easier recognition and subsequent
canonicalization of bswap patterns as discussed in PR43146:
https://bugs.llvm.org/show_bug.cgi?id=43146

We had to delay this transform because it used to allow the SLP vectorizer
to create awful reductions out of simple load-combines.
That problem was fixed with:
rL375025
(we'll bring back load combining in IR someday...)

The backend is also better equipped to deal with these patterns now
using hooks like TLI.getShiftAmountThreshold().

The only remaining potential controversy is that the -reassociate pass
tends to reverse this kind of pattern (to help GVN?). But since -reassociate
doesn't do anything with these specific patterns, there is no conflict currently.

Finally, there's a new pass proposal at D67383 for general tree-height-reduction
reassociation, and it could use a cost model to decide how to optimally rearrange
these kinds of ops for a target. That patch appears to be stalled.

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

2 years agoX86FrameLowering - fix bool to unsigned cast static analyzer warnings. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 16:48:35 +0000 (16:48 +0000)]
X86FrameLowering - fix bool to unsigned cast static analyzer warnings. NFCI.

2 years agoMachineMemOperand::getBaseAlignment() - fix "shift of i32 then extended to i64" stati...
Simon Pilgrim [Thu, 7 Nov 2019 16:46:55 +0000 (16:46 +0000)]
MachineMemOperand::getBaseAlignment() - fix "shift of i32 then extended to i64" static analyzer warning. NFCI.

2 years agoTypeRecord - fix uninitialized variable warnings. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 16:45:36 +0000 (16:45 +0000)]
TypeRecord - fix uninitialized variable warnings. NFCI.

2 years agoPostRAScheduler - fix uninitialized variable warning. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 16:45:01 +0000 (16:45 +0000)]
PostRAScheduler - fix uninitialized variable warning. NFCI.

2 years agoManagedStringPool - pre-increment iterator. NFC.
Simon Pilgrim [Thu, 7 Nov 2019 16:43:47 +0000 (16:43 +0000)]
ManagedStringPool - pre-increment iterator. NFC.

2 years agoX86CondBrFolding - remove non-existent fixBranchProb function. NFC.
Simon Pilgrim [Thu, 7 Nov 2019 16:41:48 +0000 (16:41 +0000)]
X86CondBrFolding - remove non-existent fixBranchProb function. NFC.

2 years agoAsmWriterOperand - fix uninitialized variable warning. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 15:35:07 +0000 (15:35 +0000)]
AsmWriterOperand - fix uninitialized variable warning. NFCI.

2 years agoUsing crtp to refactor the xcoff section header
diggerlin [Thu, 7 Nov 2019 16:51:34 +0000 (11:51 -0500)]
Using crtp to refactor the xcoff section header

SUMMARY:
According to https://reviews.llvm.org/D68575#inline-617586, Create a NFC patch for it.

Using crtp to refactor the xcoff section header
Move the define of SectionFlagsReservedMask and SectionFlagsTypeMask from XCOFFDumper.cpp to XCOFFObjectFile.h

Reviewers: hubert.reinterpretcast,jasonliu
Subscribers: rupprecht, seiyai,hiraditya

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

2 years ago[lldb] Comment typo fix
Jan Kratochvil [Thu, 7 Nov 2019 16:48:25 +0000 (17:48 +0100)]
[lldb] Comment typo fix

2 years agocomment shiftamountthreshold
joanlluch [Thu, 7 Nov 2019 16:41:05 +0000 (17:41 +0100)]
comment shiftamountthreshold

2 years ago[openmp] [test] Skip one more test that kills NetBSD buildbot
Michał Górny [Thu, 7 Nov 2019 16:29:13 +0000 (17:29 +0100)]
[openmp] [test] Skip one more test that kills NetBSD buildbot

2 years ago[OPENMP][DOCS] Update OpenMP status (NFC)
Alexey Bataev [Thu, 7 Nov 2019 16:07:56 +0000 (11:07 -0500)]
[OPENMP][DOCS] Update OpenMP status (NFC)

Summary: This is updating the OpenMP status table. Cray has volunteered for `defaultmap` and supporting `in_reduction` on the `target` construct, so the status on those entries from was changed from "unclaimed". Also, a new entry was added for supporting non-contiguous arrays sections on the `target update` directive.

Reviewers: ABataev, hfinkel, jdoerfert, kkwli0

Reviewed By: ABataev

Subscribers: guansong, cfe-commits

Tags: #clang

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

2 years ago[Sema] Suppress -Wchar-subscripts if the index is a literal char
Edward Jones [Thu, 7 Nov 2019 15:44:38 +0000 (15:44 +0000)]
[Sema] Suppress -Wchar-subscripts if the index is a literal char

Assume that the user knows what they're doing if they provide a char
literal as an array index. This more closely matches the behavior of
GCC.

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

2 years ago[GWP-ASan] Respect compiler-rt's -fno-lto
Mitch Phillips [Thu, 7 Nov 2019 15:41:08 +0000 (07:41 -0800)]
[GWP-ASan] Respect compiler-rt's -fno-lto

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

GWP-ASan didn't include SANITIZER_COMMON_CFLAGS, and thus would produce
LLVM bitcode files, when compiler-rt is generally built without LTO.

2 years ago[RISCV] Add riscv{32,64} to ALL_CRT_SUPPORTED_ARCH list
Edward Jones [Thu, 3 Oct 2019 14:00:55 +0000 (15:00 +0100)]
[RISCV] Add riscv{32,64} to ALL_CRT_SUPPORTED_ARCH list

This allows crtbegin and crtend to be built, allowing RISC-V
to no longer rely on implementations from libgcc.

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

2 years ago[SDAG] reduce code duplication; NFC
Sanjay Patel [Thu, 7 Nov 2019 15:28:25 +0000 (10:28 -0500)]
[SDAG] reduce code duplication; NFC

2 years agoAdd support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-except...
Melanie Blower [Tue, 5 Nov 2019 21:41:21 +0000 (13:41 -0800)]
Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior=

    Add options to control floating point behavior: trapping and
    exception behavior, rounding, and control of optimizations that affect
    floating point calculations. More details in UsersManual.rst.

    Reviewers: rjmccall

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

2 years ago[RISCV] Improve sysroot computation if no GCC install detected
Edward Jones [Thu, 3 Oct 2019 13:49:08 +0000 (14:49 +0100)]
[RISCV] Improve sysroot computation if no GCC install detected

If a GCC installed is not detected, the driver would default to
the root of the filesystem. This is not ideal when this doesn't
match the install directory of the toolchain and can cause
undesireable behavior such as picking up system libraries or
the system linker when cross-compiling.

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

2 years ago[SDAG] reduce code duplication; NFC
Sanjay Patel [Thu, 7 Nov 2019 15:14:49 +0000 (10:14 -0500)]
[SDAG] reduce code duplication; NFC

2 years ago[OpenCL] Add geometric and relational builtin functions
Sven van Haastregt [Thu, 7 Nov 2019 15:00:19 +0000 (15:00 +0000)]
[OpenCL] Add geometric and relational builtin functions

Add the geometric and relational builtin functions from the OpenCL C
specification.

Patch by Pierre Gondois and Sven van Haastregt.

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

2 years ago[OpenCL] Add integer builtin functions
Sven van Haastregt [Wed, 6 Nov 2019 11:53:19 +0000 (11:53 +0000)]
[OpenCL] Add integer builtin functions

This patch adds the integer builtin functions from the OpenCL C
specification.

Patch by Pierre Gondois and Sven van Haastregt.

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

2 years ago[lldb] Add -m option to 'target modules dump symtab' to disable demangling
Raphael Isemann [Thu, 7 Nov 2019 14:47:01 +0000 (15:47 +0100)]
[lldb] Add -m option to 'target modules dump symtab' to disable demangling

Summary: This option was added downstream in swift-lldb. This upstreams this option as it seems useful and also adds the missing tests.

Reviewers: #lldb, kwk, labath

Reviewed By: kwk, labath

Subscribers: labath, kwk, abidh, JDevlieghere, lldb-commits

Tags: #lldb, #upstreaming_lldb_s_downstream_patches

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

2 years agoSampleProfWriter - fix uninitialized variable warnings. NFCI.
Simon Pilgrim [Thu, 7 Nov 2019 13:51:35 +0000 (13:51 +0000)]
SampleProfWriter - fix uninitialized variable warnings. NFCI.

2 years agoCodeGen: set correct result for atomic compound expressions
Tim Northover [Thu, 7 Nov 2019 13:36:03 +0000 (13:36 +0000)]
CodeGen: set correct result for atomic compound expressions

Atomic compound expressions try to use atomicrmw if possible, but this
path doesn't set the Result variable, leaving it to crash in later code
if anything ever tries to use the result of the expression. This fixes
that issue by recalculating the new value based on the old one
atomically loaded.

2 years ago[libc++] Fix potential OOB in poisson_distribution
Louis Dionne [Thu, 7 Nov 2019 12:06:14 +0000 (12:06 +0000)]
[libc++] Fix potential OOB in poisson_distribution

See details in the original Chromium bug report:
    https://bugs.chromium.org/p/chromium/issues/detail?id=994957

2 years ago[ConstantRange][LVI] Use overflow flags from `sub` to constrain the range
Roman Lebedev [Thu, 7 Nov 2019 13:18:03 +0000 (16:18 +0300)]
[ConstantRange][LVI] Use overflow flags from `sub` to constrain the range

Summary:
This notably improves non-negativity deduction:
```
| statistic                              |     old |     new | delta | % change |
| correlated-value-propagation.NumAShrs  |     209 |     227 |    18 |  8.6124% |
| correlated-value-propagation.NumAddNSW |    4972 |    4988 |    16 |  0.3218% |
| correlated-value-propagation.NumAddNUW |    7141 |    7148 |     7 |  0.0980% |
| correlated-value-propagation.NumAddNW  |   12113 |   12136 |    23 |  0.1899% |
| correlated-value-propagation.NumAnd    |     442 |     445 |     3 |  0.6787% |
| correlated-value-propagation.NumNSW    |    7160 |    7176 |    16 |  0.2235% |
| correlated-value-propagation.NumNUW    |   13306 |   13316 |    10 |  0.0752% |
| correlated-value-propagation.NumNW     |   20466 |   20492 |    26 |  0.1270% |
| correlated-value-propagation.NumSDivs  |     207 |     212 |     5 |  2.4155% |
| correlated-value-propagation.NumSExt   |    6279 |    6679 |   400 |  6.3704% |
| correlated-value-propagation.NumSRems  |      28 |      29 |     1 |  3.5714% |
| correlated-value-propagation.NumShlNUW |    2793 |    2796 |     3 |  0.1074% |
| correlated-value-propagation.NumShlNW  |    3964 |    3967 |     3 |  0.0757% |
| correlated-value-propagation.NumUDivs  |     353 |     358 |     5 |  1.4164% |
| instcount.NumAShrInst                  |   13763 |   13741 |   -22 | -0.1598% |
| instcount.NumAddInst                   |  277349 |  277348 |    -1 | -0.0004% |
| instcount.NumLShrInst                  |   27437 |   27463 |    26 |  0.0948% |
| instcount.NumOrInst                    |  102677 |  102678 |     1 |  0.0010% |
| instcount.NumSDivInst                  |    8732 |    8727 |    -5 | -0.0573% |
| instcount.NumSExtInst                  |   80872 |   80468 |  -404 | -0.4996% |
| instcount.NumSRemInst                  |    1679 |    1678 |    -1 | -0.0596% |
| instcount.NumTruncInst                 |   62154 |   62153 |    -1 | -0.0016% |
| instcount.NumUDivInst                  |    2526 |    2527 |     1 |  0.0396% |
| instcount.NumURemInst                  |    1589 |    1590 |     1 |  0.0629% |
| instcount.NumZExtInst                  |   69405 |   69809 |   404 |  0.5821% |
| instcount.TotalInsts                   | 7439575 | 7439574 |    -1 |  0.0000% |
```

Reviewers: nikic, reames, spatel

Reviewed By: nikic

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

2 years ago[OpenCL] Add math and common builtin functions
Sven van Haastregt [Tue, 5 Nov 2019 19:47:21 +0000 (19:47 +0000)]
[OpenCL] Add math and common builtin functions

Add the remaining math and common builtin functions from the OpenCL C
specification.

Patch by Pierre Gondois and Sven van Haastregt.

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

2 years ago[libc++] Fixed copy/copy_n/copy_backward for compilers that do not support is_constan...
Louis Dionne [Thu, 7 Nov 2019 12:30:32 +0000 (12:30 +0000)]
[libc++] Fixed copy/copy_n/copy_backward for compilers that do not support is_constant_evaluated.

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

2 years ago[libc++] Fix some constexpr tests broken by D68837
Louis Dionne [Wed, 6 Nov 2019 14:52:26 +0000 (14:52 +0000)]
[libc++] Fix some constexpr tests broken by D68837

This doesn't fix all the issues with D68837

2 years ago[ThinLTO] Import readonly vars with refs
evgeny [Thu, 7 Nov 2019 12:13:35 +0000 (15:13 +0300)]
[ThinLTO] Import readonly vars with refs

Patch allows importing declarations of functions and variables, referenced
by the initializer of some other readonly variable.
Differential revision: https://reviews.llvm.org/D69561

2 years ago[SLP] allow forming 2-way reduction patterns
Sanjay Patel [Wed, 6 Nov 2019 22:24:09 +0000 (17:24 -0500)]
[SLP] allow forming 2-way reduction patterns

We have a vector compare reduction problem seen in PR39665 comment 2:
https://bugs.llvm.org/show_bug.cgi?id=39665#c2

Or slightly reduced here:

define i1 @cmp2(<2 x double> %a0) {
  %a = fcmp ogt <2 x double> %a0, <double 1.0, double 1.0>
  %b = extractelement <2 x i1> %a, i32 0
  %c = extractelement <2 x i1> %a, i32 1
  %d = and i1 %b, %c
  ret i1 %d
}

SLP would not attempt to turn this into a vector reduction because there is an
artificial lower limit on that transform. We can not completely remove that limit
without inducing regressions though, so this patch just hacks an extra attempt at
creating a 2-way reduction to the end of the analysis.

As shown in the test file, we are still not getting some of the motivating cases,
so follow-on patches will be needed to solve those cases.

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

2 years ago[NFC][CVP] Add some tests for `sub` with preexisting no-wrap flags
Roman Lebedev [Thu, 7 Nov 2019 10:59:26 +0000 (13:59 +0300)]
[NFC][CVP] Add some tests for `sub` with preexisting no-wrap flags

We can use those to further limit the ranges in LVI.

2 years ago[mips] Set macros for Octeon+ CPU
Simon Atanasyan [Tue, 5 Nov 2019 08:21:04 +0000 (11:21 +0300)]
[mips] Set macros for Octeon+ CPU

2 years ago[mips] Add `octeon+` to the list of CPUs accepted by the driver
Simon Atanasyan [Mon, 4 Nov 2019 23:21:16 +0000 (02:21 +0300)]
[mips] Add `octeon+` to the list of CPUs accepted by the driver

2 years ago[mips] Write `AFL_EXT_OCTEONP` flag to the `.MIPS.abiflags` section
Simon Atanasyan [Mon, 4 Nov 2019 22:26:24 +0000 (01:26 +0300)]
[mips] Write `AFL_EXT_OCTEONP` flag to the `.MIPS.abiflags` section

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

2 years ago[mips] Support `octeon+` CPU in the `.set arch=` directive
Simon Atanasyan [Mon, 4 Nov 2019 22:23:59 +0000 (01:23 +0300)]
[mips] Support `octeon+` CPU in the `.set arch=` directive

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

2 years ago[mips] Implement Octeon+ `saa` and `saad` instructions
Simon Atanasyan [Mon, 4 Nov 2019 22:12:10 +0000 (01:12 +0300)]
[mips] Implement Octeon+ `saa` and `saad` instructions

`saa` and `saad` are 32-bit and 64-bit store atomic add instructions.

   memory[base] = memory[base] + rt

These instructions are available for "Octeon+" CPU. The patch adds support
for both instructions to MIPS assembler and diassembler and introduces new
CPU type - "octeon+".

Next patches will implement `.set arch=octeon+` directive and `AFL_EXT_OCTEONP`
ISA extension flag support.

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

2 years agoRevert f0c2a5a "[LV] Generalize conditions for sinking instrs for first order recurre...
Hans Wennborg [Thu, 7 Nov 2019 10:00:02 +0000 (11:00 +0100)]
Revert f0c2a5a "[LV] Generalize conditions for sinking instrs for first order recurrences."

It broke Chromium, causing "Instruction does not dominate all uses!" errors.
See https://bugs.chromium.org/p/chromium/issues/detail?id=1022297#c1 for a
reproducer.

> If the recurrence PHI node has a single user, we can sink any
> instruction without side effects, given that all users are dominated by
> the instruction computing the incoming value of the next iteration
> ('Previous'). We can sink instructions that may cause traps, because
> that only causes the trap to occur later, but not on any new paths.
>
> With the relaxed check, we also have to make sure that we do not have a
> direct cycle (meaning PHI user == 'Previous), which indicates a
> reduction relation, which potentially gets missed by
> ReductionDescriptor.
>
> As follow-ups, we can also sink stores, iff they do not alias with
> other instructions we move them across and we could also support sinking
> chains of instructions and multiple users of the PHI.
>
> Fixes PR43398.
>
> Reviewers: hsaito, dcaballe, Ayal, rengolin
>
> Reviewed By: Ayal
>
> Differential Revision: https://reviews.llvm.org/D69228

2 years ago[clangd] NFC, hide the internal-only utility function lex.
Haojian Wu [Thu, 7 Nov 2019 09:53:19 +0000 (10:53 +0100)]
[clangd] NFC, hide the internal-only utility function lex.

To avoid any potential ODR violations.

2 years ago[lldb-server] Add setting to force 'g' packet use
Guilherme Andrade [Thu, 7 Nov 2019 09:38:25 +0000 (10:38 +0100)]
[lldb-server] Add setting to force 'g' packet use

Following up on https://reviews.llvm.org/D62221, this change introduces
the settings plugin.process.gdb-remote.use-g-packet-for-reading.  When
they are on, 'g' packets are used for reading registers.

Using 'g' packets can improve performance by reducing the number of
packets exchanged between client and server when a large number of
registers needs to be fetched.

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

2 years ago[clang-rename] Respect the traversal scope when traversing the entire AST.
Haojian Wu [Wed, 6 Nov 2019 14:21:40 +0000 (15:21 +0100)]
[clang-rename] Respect the traversal scope when traversing the entire AST.

Summary:
This should be NFC to clang-rename, by default the traversal scope is
TUDecl. Traversing the TUDecl in clangd is a performance cliff, we should
avoid it.

Reviewers: ilya-biryukov

Subscribers: kadircet, usaxena95, cfe-commits

Tags: #clang

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

2 years agoRevert a5c8ec4 "[CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood"
Hans Wennborg [Thu, 7 Nov 2019 09:23:24 +0000 (10:23 +0100)]
Revert a5c8ec4 "[CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood"

This caused Chromium builds to fail with "inlinable function call in a function
with debug info must have a !dbg location" errors. See
https://bugs.chromium.org/p/chromium/issues/detail?id=1022296#c1 for a
reproducer.

> Currently, clang emits subprograms for declared functions when the
> target debugger or DWARF standard is known to support entry values
> (DW_OP_entry_value & the GNU equivalent).
>
> Treat DW_AT_tail_call the same way to allow debuggers to follow cross-TU
> tail calls.
>
> Pre-patch debug session with a cross-TU tail call:
>
> ```
>   * frame #0: 0x0000000100000fa4 main`target at b.c:4:3 [opt]
>     frame #1: 0x0000000100000f99 main`main at a.c:8:10 [opt]
> ```
>
> Post-patch (note that the tail-calling frame, "helper", is visible):
>
> ```
>   * frame #0: 0x0000000100000fa4 main`target at b.c:4:3 [opt]
>     frame #1: 0x0000000100000f80 main`helper [opt] [artificial]
>     frame #2: 0x0000000100000f99 main`main at a.c:8:10 [opt]
> ```
>
> rdar://46577651
>
> Differential Revision: https://reviews.llvm.org/D69743

2 years ago[clangd] Add unit tests for comments in system headers
Ilya Biryukov [Thu, 7 Nov 2019 08:59:36 +0000 (09:59 +0100)]
[clangd] Add unit tests for comments in system headers

2 years ago[clang-format] Make '.clang-format' variants finding a loop (NFC)
Anders Waldenborg [Thu, 7 Nov 2019 08:59:34 +0000 (09:59 +0100)]
[clang-format] Make '.clang-format' variants finding a loop (NFC)

This simplifies logic making it trivial to add searching for other
files later.

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

2 years ago[clangd] Set RetainCommentsFromSystemHeaders to true
Ilya Biryukov [Thu, 7 Nov 2019 08:53:07 +0000 (09:53 +0100)]
[clangd] Set RetainCommentsFromSystemHeaders to true

clangd should retain comments from system headers.

fixes https://github.com/clangd/clangd/issues/96

Patch by lh123!

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

2 years ago[AMDGPU] Fix bug introduced in 47a5c36b37f0
dfukalov [Wed, 6 Nov 2019 19:05:58 +0000 (22:05 +0300)]
[AMDGPU] Fix bug introduced in 47a5c36b37f0

Summary: [AMDGPU] Fix bug introduced in 47a5c36b37f0

Reviewers: foad, arsenm

Reviewed By: arsenm

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

Tags: #llvm

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

2 years ago[Syntax] Silence "unused function" warning in no-assert builds. NFC
Ilya Biryukov [Thu, 7 Nov 2019 08:37:25 +0000 (09:37 +0100)]
[Syntax] Silence "unused function" warning in no-assert builds. NFC

A helper `isImpicitExpr` is only used inside assert.

2 years ago[llvm-readobj] - Simplify elf-hash-symbols.test. NFCI.
Georgii Rymar [Wed, 6 Nov 2019 09:11:44 +0000 (12:11 +0300)]
[llvm-readobj] - Simplify elf-hash-symbols.test. NFCI.

It converts binary contents of .hash and .gnu.hash that were generated by a linker
to YAML descriptions.
I've also dropped Shift2 and BloomFilter values because they are not needed here.

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

2 years ago[X86] Remove unused variable. NFC
Craig Topper [Thu, 7 Nov 2019 06:53:48 +0000 (22:53 -0800)]
[X86] Remove unused variable. NFC

2 years ago[X86] Remove dead code from combineStore.
Craig Topper [Thu, 7 Nov 2019 06:24:05 +0000 (22:24 -0800)]
[X86] Remove dead code from combineStore.

Leftovers from before we switched to widening legalization.

Fixes PR43919.

2 years ago[Clang] Add ENABLE_LINKER_BUILD_ID to Hurd driver.
kristina [Thu, 7 Nov 2019 05:38:24 +0000 (05:38 +0000)]
[Clang] Add ENABLE_LINKER_BUILD_ID to Hurd driver.

This was added for Linux toolchains in rC271692, this
patch extends this to the Hurd toolchain.

Patch by sthibaul (Samuel Thibault)

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

2 years agoTemporarily Revert "[LV] Apply sink-after & interleave-groups as VPlan transformation...
Eric Christopher [Thu, 7 Nov 2019 05:58:28 +0000 (21:58 -0800)]
Temporarily Revert "[LV] Apply sink-after & interleave-groups as VPlan transformations (NFC)"
as it's causing assert failures.

This reverts commit 100e797adb433724a17c9b42b6533cd634cb796b.

2 years ago[OPENMP] [DOCS] fix section formatting issues [NFC]
Kelvin Li [Wed, 6 Nov 2019 18:25:16 +0000 (13:25 -0500)]
[OPENMP] [DOCS] fix section formatting issues [NFC]

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

2 years agoKeep import function list for inlinee profile update
Wenlei He [Fri, 1 Nov 2019 19:57:23 +0000 (12:57 -0700)]
Keep import function list for inlinee profile update

Summary:
When adjusting function entry counts after inlining, Funciton::setEntryCount is called without providing an import function list. The side effect of that is the previously set import function list will be dropped. The import function list is used by ThinLTO to help import hot cross module callee for LTO inlining, so dropping that during ThinLTO pre-link may adversely affect LTO inlining. The fix is to keep the list while updating entry counts for inlining.

Reviewers: wmi, davidxl, tejohnson

Subscribers: mehdi_amini, hiraditya, dexonsmith, llvm-commits

Tags: #llvm

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

2 years ago[AArch64][SVE] Add remaining patterns and intrinsics for add/sub/mad patterns
Danilo Carvalho Grael [Wed, 6 Nov 2019 22:02:58 +0000 (17:02 -0500)]
[AArch64][SVE] Add remaining patterns and intrinsics for add/sub/mad patterns

Add pattern matching and intrinsics for the following instructions:

predicated orr, eor, and, bic
predicated mul, smulh, umulh, sdiv, udiv, sdivr, udivr
predicated smax, umax, smin, umin, sabd, uabd
mad, msb, mla, mls

https://reviews.llvm.org/D69588

2 years agoRevert "gn build: (manually) merge b5913e6d2f"
Nico Weber [Thu, 7 Nov 2019 01:52:29 +0000 (20:52 -0500)]
Revert "gn build: (manually) merge b5913e6d2f"

This reverts commit c52efdc52cef2597a1d21595a9685e2f798025b8,
because b5913e6d2f got reverted.

2 years agoRevert "Introduce llvm-install-name-tool"
Alexander Shaposhnikov [Thu, 7 Nov 2019 01:04:04 +0000 (17:04 -0800)]
Revert "Introduce llvm-install-name-tool"

This reverts commit b5913e6d2f6d13fb753df701619731ca11936316.

2 years agoAMDGPU: Select global atomicrmw fadd
Matt Arsenault [Thu, 29 Aug 2019 18:53:17 +0000 (14:53 -0400)]
AMDGPU: Select global atomicrmw fadd

This only works if there is no use of the return value.

2 years agoTableGen: Remove assert that pattern results match input number
Matt Arsenault [Thu, 29 Aug 2019 19:10:12 +0000 (15:10 -0400)]
TableGen: Remove assert that pattern results match input number

AMDGPU has some atomic instructions that do not return the previous
result, and can only be selected if there are no uses. The source
pattern will only match if the use is empty, so it should be safe to
discard the result.

2 years agoTemporarily Revert:
Eric Christopher [Wed, 6 Nov 2019 23:56:41 +0000 (15:56 -0800)]
Temporarily Revert:

 "[SLP] Generalization of stores vectorization."
 "[SLP] Fix -Wunused-variable. NFC"
 "[SLP] Vectorize jumbled stores."

As they're causing significant (10-30x) compile time regressions on
vectorizable code.

The primary cause of the compile-time regression is f228b5371647f471853c5fb3e6719823a42fe451.

This reverts commits:

f228b5371647f471853c5fb3e6719823a42fe451
5503455ccb3f5fcedced158332c016c8d3a7fa81
21d498c9c0f32dcab5bc89ac593aa813b533b43a

2 years ago[LLDB] Adding caching to libc++ std::function formatter for lookups that require...
shafik [Wed, 6 Nov 2019 23:57:52 +0000 (15:57 -0800)]
[LLDB] Adding caching to libc++ std::function formatter for lookups that require scanning symbols

Performance issues lead to the libc++ std::function formatter to be disabled.
This change is the first of two changes that should address the performance issues and allow us to enable the formatter again.
In some cases we end up scanning the symbol table for the callable wrapped by std::function for those cases we will now cache the results and used the cache in subsequent look-ups. This still leaves a large cost for the initial lookup which will be addressed in the next change.

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

2 years ago[AMDGPU] Add handling of 160 bit registers in analyzeResourceUsage
Stanislav Mekhanoshin [Wed, 6 Nov 2019 20:39:38 +0000 (12:39 -0800)]
[AMDGPU] Add handling of 160 bit registers in analyzeResourceUsage

This was omitted. Also SReg_96Reg missed IsSGPR assignment.

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

2 years agounwind: restore the LINKER_LANGUAGE
Saleem Abdulrasool [Wed, 6 Nov 2019 23:40:07 +0000 (15:40 -0800)]
unwind: restore the LINKER_LANGUAGE

Have CMake treat the unwind libraries as C libraries rather than C++.
There is no C++ runtime dependency at runtime.  This ensures that we do
not accidentally end up with a link against the C++ runtime.

We need to explicitly reset the implicitly linked libraries for C++ to
ensure that we do not have CMake force the link against the C++ runtime.
This adjustment should enable the NetBSD bots to be happy with this
change.

2 years agounwind: reflow some of the build rules (NFC)
Saleem Abdulrasool [Wed, 6 Nov 2019 23:38:25 +0000 (15:38 -0800)]
unwind: reflow some of the build rules (NFC)

Reflow the CMake properties to take less vertical space.  This just
makes it easier to read.  NFC.

2 years ago[LoopPred] Enable new transformation by default
Philip Reames [Wed, 6 Nov 2019 23:30:47 +0000 (15:30 -0800)]
[LoopPred] Enable new transformation by default

The basic idea of the transform is to convert variant loop exit conditions into invariant exit conditions by changing the iteration on which the exit is taken when we know that the trip count is unobservable.  See the original patch which introduced the code for a more complete explanation.

The individual parts of this have been reviewed, the result has been fuzzed, and then further analyzed by hand, but despite all of that, I will not be suprised to see breakage here.  If you see problems, please don't hesitate to revert - though please do provide a test case.  The most likely class of issues are latent SCEV bugs and without a reduced test case, I'll be essentially stuck on reducing them.

(Note: A bunch of tests were opted out of the new transform to preserve coverage.  That landed in a previous commit to simplify revert cycles if they turn out to be needed.)

2 years ago[LoopPred] Selectively disable to preserve test cases
Philip Reames [Wed, 6 Nov 2019 23:16:43 +0000 (15:16 -0800)]
[LoopPred] Selectively disable to preserve test cases

I'm about to enable the new loop predication transform by default.  It has the effect of completely destroying many read only loops - which happen to be a super common idiom in our test cases.  So as to preserve test coverage of other transforms, disable the new transform where it would cause sharp test coverage regressions.

(This is semantically part of the enabling commit.  It's committed separate to ease revert if the actual flag flip gets reverted.)

2 years agogn build: (manually) merge b5913e6d2f
Nico Weber [Wed, 6 Nov 2019 23:26:36 +0000 (18:26 -0500)]
gn build: (manually) merge b5913e6d2f

2 years agoWhen lowering calls and tail calls in AArch64, the register mask and
Eric Christopher [Wed, 6 Nov 2019 23:16:19 +0000 (15:16 -0800)]
When lowering calls and tail calls in AArch64, the register mask and
return value location depends on the calling convention of the callee.
`F.getCallingConv()`, however, is the caller CC. Correct it to the
callee CC from `CallLoweringInfo`.

Fixes PR43449

Patch by Shu-Chun Weng!

2 years ago[lldb] Mark ASan & TSan as test dependencies
Jonas Devlieghere [Wed, 6 Nov 2019 23:22:17 +0000 (15:22 -0800)]
[lldb] Mark ASan & TSan as test dependencies

Without asan and tsan as test dependencies, you might end up with a
clang that points to sanitizer runtime library that hasn't been build
yet.

2 years ago[test] Fix apple_simulator_test decorator when simulators are unavailable
Alex Langford [Wed, 6 Nov 2019 23:12:31 +0000 (15:12 -0800)]
[test] Fix apple_simulator_test decorator when simulators are unavailable

In the case where xcodebuild fails as you set up simulator tests, you
would fail because `feature` is never defined.