platform/upstream/llvm.git
4 years ago[libc++] Add `__truncating_cast` for safely casting float types to integers
Louis Dionne [Wed, 4 Sep 2019 12:48:32 +0000 (12:48 +0000)]
[libc++] Add `__truncating_cast` for safely casting float types to integers

This is needed anytime we need to clamp an arbitrary floating point
value to an integer type.

Thanks to Eric Fiselier for the patch.

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

llvm-svn: 370891

4 years ago[NFC] Added a negative test for new fold
David Bolvansky [Wed, 4 Sep 2019 12:46:25 +0000 (12:46 +0000)]
[NFC] Added a negative test for new fold

llvm-svn: 370890

4 years ago[libc++] Use __extension__ in a portable manner
Louis Dionne [Wed, 4 Sep 2019 12:44:19 +0000 (12:44 +0000)]
[libc++] Use __extension__ in a portable manner

llvm-svn: 370889

4 years ago[NFC] Fixed test
David Bolvansky [Wed, 4 Sep 2019 12:43:14 +0000 (12:43 +0000)]
[NFC] Fixed test

llvm-svn: 370888

4 years ago[lldb] Fix log statement in Socket::Write
Raphael Isemann [Wed, 4 Sep 2019 12:38:43 +0000 (12:38 +0000)]
[lldb] Fix log statement in Socket::Write

We change num_bytes in this method, so this doesn't actually
log the parameter that we called the function with. No test
as we don't test logging code.

llvm-svn: 370887

4 years ago[NFC] Adjust tests for new fold
David Bolvansky [Wed, 4 Sep 2019 12:22:28 +0000 (12:22 +0000)]
[NFC] Adjust tests for new fold

llvm-svn: 370886

4 years ago[NFC] Added tests for new fold
David Bolvansky [Wed, 4 Sep 2019 12:18:53 +0000 (12:18 +0000)]
[NFC] Added tests for new fold

llvm-svn: 370885

4 years ago[clangd] Fix SelectionTree behavior on implicit 'this'
Sam McCall [Wed, 4 Sep 2019 12:15:20 +0000 (12:15 +0000)]
[clangd] Fix SelectionTree behavior on implicit 'this'

llvm-svn: 370884

4 years ago[InstCombine] Fold sub (or A, B) (and A, B) to (xor A, B)
David Bolvansky [Wed, 4 Sep 2019 12:00:33 +0000 (12:00 +0000)]
[InstCombine] Fold sub (or A, B) (and A, B) to (xor A, B)

Summary:
```
Name: sub or and to xor
%or = or i32 %y, %x
%and = and i32 %x, %y
%sub = sub i32 %or, %and
  =>
%sub = xor i32 %x, %y

Optimization: sub or and to xor
Done: 1
Optimization is correct!
```
https://rise4fun.com/Alive/eJu

Reviewers: spatel, lebedev.ri

Reviewed By: lebedev.ri

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 370883

4 years agoFix address sizes in the dwarfdump-debug-loc-error-cases test
Pavel Labath [Wed, 4 Sep 2019 11:47:20 +0000 (11:47 +0000)]
Fix address sizes in the dwarfdump-debug-loc-error-cases test

the test is building a 64-bit executable, so the addresses should be
64-bit too. The test was still passing even with smaller address size,
but it was hitting the "unexpected end of data" error sooner than it
should.

llvm-svn: 370882

4 years ago[NFC] Added a new test for D67153
David Bolvansky [Wed, 4 Sep 2019 11:44:00 +0000 (11:44 +0000)]
[NFC] Added a new test for D67153

llvm-svn: 370881

4 years ago[lldb] Limit the amount of zeroes we use for padding when printing small floats
Raphael Isemann [Wed, 4 Sep 2019 11:41:23 +0000 (11:41 +0000)]
[lldb] Limit the amount of zeroes we use for padding when printing small floats

Summary:
We got a radar that printing small floats is not very user-friendly in LLDB as we print them with up to
100 leading zeroes before starting to use scientific notation. This patch changes this by already using
scientific notation when we hit 6 padding zeroes by default and moves this value into a target setting
so that users can just set this number back to 100 if they for some reason preferred the old behaviour.

This new setting is influencing how we format data, so that's why we have to reset the data visualisation
cache when it is changed.

Note that we have always been using scientific notation for large numbers because it seems that
the LLVM implementation doesn't support printing out the padding zeroes for them. I would have fixed
that if it was trivial, but looking at the LLVM implementation for this it seems that this is not as trivial
as it sounds. I would say we look into this if we ever get a bug report about someone wanting to have
a large amount of trailing zeroes in their numbers instead of using scientific notation.

Fixes rdar://39744137

Reviewers: #lldb, clayborg

Reviewed By: clayborg

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 370880

4 years ago[lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain
Raphael Isemann [Wed, 4 Sep 2019 11:40:29 +0000 (11:40 +0000)]
[lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

Summary:
We currently spend a lot of time in this function (around 27% of the br-by-regex benchmark in lldb-bench)
by just iterating over all the ranges. We already sorted these ranges by their base address, we we can actually
just stop checking ranges as soon as we find one that has a higher base address.

Reviewers: labath

Reviewed By: labath

Subscribers: amccarth, arphaman, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 370879

4 years ago[NFC] Added tests for 'SUB of OR and AND to XOR' fold
David Bolvansky [Wed, 4 Sep 2019 11:17:08 +0000 (11:17 +0000)]
[NFC] Added tests for 'SUB of OR and AND to XOR' fold

llvm-svn: 370878

4 years ago[DebugInfo] LiveDebugValues: locations with different exprs should not be merged
Jeremy Morse [Wed, 4 Sep 2019 11:09:05 +0000 (11:09 +0000)]
[DebugInfo] LiveDebugValues: locations with different exprs should not be merged

When comparing variable locations, LiveDebugValues currently considers only
the machine location, ignoring any DIExpression applied to it. This is a
problem because that DIExpression can do pretty much anything to the machine
location, for example dereferencing it.

This patch adds DIExpressions to that comparison; now variables based on the
same register/memory-location but with different expressions will compare
differently, and be dropped if we attempt to merge them between blocks. This
reduces variable coverage-range a little, but only because we were producing
broken locations.

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

llvm-svn: 370877

4 years agogn build: Merge r370862
Nico Weber [Wed, 4 Sep 2019 11:08:09 +0000 (11:08 +0000)]
gn build: Merge r370862

llvm-svn: 370876

4 years ago[ELF] Fix spell corrector: don't call elf::InputFile::getSymbols() on shared objects
Fangrui Song [Wed, 4 Sep 2019 11:02:58 +0000 (11:02 +0000)]
[ELF] Fix spell corrector: don't call elf::InputFile::getSymbols() on shared objects

Exposed by pr34872.s

llvm-svn: 370875

4 years agoRevert "[Clang Interpreter] Initial patch for the constexpr interpreter"
Roman Lebedev [Wed, 4 Sep 2019 10:57:06 +0000 (10:57 +0000)]
Revert "[Clang Interpreter] Initial patch for the constexpr interpreter"

Breaks BUILD_SHARED_LIBS build, introduces cycles in library dependency
graphs. (clangInterp depends on clangAST which depends on clangInterp)

This reverts r370839, which is an yet another recommit of D64146.

llvm-svn: 370874

4 years ago[cmake] Remove MSVC C4180 override
Simon Pilgrim [Wed, 4 Sep 2019 10:26:39 +0000 (10:26 +0000)]
[cmake] Remove MSVC C4180 override

Tested on VS2017 and VS2019 llvm/clang builds with WX enabled - its no longer necessary to disable this warning.

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

llvm-svn: 370871

4 years ago[LiveDebugValues][NFC] Silence an unused variable warning
Jeremy Morse [Wed, 4 Sep 2019 10:18:03 +0000 (10:18 +0000)]
[LiveDebugValues][NFC] Silence an unused variable warning

On release builds, 'MI' isn't used by anything (it's already inserted into a
block by BuildMI), while on non-release builds it's used by a LLVM_DEBUG
statement. Mark as explicitly used to avoid the warning.

llvm-svn: 370870

4 years ago[clangd] Remove macro-expansion-location from getBeginningOfIdentifier. Inline into...
Sam McCall [Wed, 4 Sep 2019 10:15:27 +0000 (10:15 +0000)]
[clangd] Remove macro-expansion-location from getBeginningOfIdentifier. Inline into relevant callsites. NFC

llvm-svn: 370869

4 years agoDWARF: Fix a regression in location list dumping
Pavel Labath [Wed, 4 Sep 2019 10:09:12 +0000 (10:09 +0000)]
DWARF: Fix a regression in location list dumping

Summary:
While fixing the handling of some error cases, r370363 introduced new
problems -- assertion failures due to unchecked errors (my excuse is that a very
early version of that patch used Optional<T> instead of Expected).

This patch adds proper handling of parsing errors encountered when
dumping location lists from inside DWARF DIEs, and adds a bunch of
additional tests.

I reorder the arguments of the location list dumping functions to make
them consistent, and also be able to dump the two kinds of location
lists generically.

Reviewers: JDevlieghere, dblaikie, probinson

Subscribers: aprantl, llvm-commits

Tags: #llvm

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

llvm-svn: 370868

4 years ago[cmake] Remove MSVC C4258 override
Simon Pilgrim [Wed, 4 Sep 2019 10:01:31 +0000 (10:01 +0000)]
[cmake] Remove MSVC C4258 override

Tested on VS2017 and VS2019 llvm/clang builds with WX enabled - its no longer necessary to disable this warning.

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

llvm-svn: 370866

4 years ago[clangd] Remove obsolete includes. NFC
Sam McCall [Wed, 4 Sep 2019 10:01:05 +0000 (10:01 +0000)]
[clangd] Remove obsolete includes. NFC

llvm-svn: 370865

4 years ago[clangd] Move threading helper to more appropriate header. NFC
Sam McCall [Wed, 4 Sep 2019 09:53:24 +0000 (09:53 +0000)]
[clangd] Move threading helper to more appropriate header. NFC

llvm-svn: 370864

4 years agoCode cleanup: Change FormattersContainer::KeyType from SP to rvalue
Jan Kratochvil [Wed, 4 Sep 2019 09:47:18 +0000 (09:47 +0000)]
Code cleanup: Change FormattersContainer::KeyType from SP to rvalue

There is now std::shared_ptr passed around which is expensive for manycore
CPUs. Most of the times (except for 3 cases) it is now just std::moved with no
CPU locks needed. It also makes it possible to sort the keys (which is now not
needed much after D66398).

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

llvm-svn: 370863

4 years ago[clangd] Rename ClangdUnit.h -> ParsedAST.h. NFC
Sam McCall [Wed, 4 Sep 2019 09:46:06 +0000 (09:46 +0000)]
[clangd] Rename ClangdUnit.h -> ParsedAST.h. NFC

This much better reflects what is (now) in this header.
Maybe a rename to ParsedTU would be an improvement, but that's a much
more invasive change and life is too short.

ClangdUnit is dead, long live ClangdUnitTests!

llvm-svn: 370862

4 years ago[llvm-dwarfdump] Fix spelling in the comments. NFC
Djordje Todorovic [Wed, 4 Sep 2019 09:44:09 +0000 (09:44 +0000)]
[llvm-dwarfdump] Fix spelling in the comments. NFC

llvm-svn: 370861

4 years ago[llvm-objcopy] Add objcopy::elf::Object::allocSections to simplify loops on SHF_ALLOC...
Fangrui Song [Wed, 4 Sep 2019 09:35:32 +0000 (09:35 +0000)]
[llvm-objcopy] Add objcopy::elf::Object::allocSections to simplify loops on SHF_ALLOC sections

Reviewed By: jhenderson

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

llvm-svn: 370860

4 years agoAdd LLDB reformatting to .git-blame-ignore-revs
Raphael Isemann [Wed, 4 Sep 2019 09:31:55 +0000 (09:31 +0000)]
Add LLDB reformatting to .git-blame-ignore-revs

llvm-svn: 370859

4 years agoPort TestBatchMode to PExpectTest class
Pavel Labath [Wed, 4 Sep 2019 09:20:08 +0000 (09:20 +0000)]
Port TestBatchMode to PExpectTest class

Summary:
I'm doing this mainly for consistency, but there are also other cleanups
that will be enabled by this (e.g., the automatic setting of
clang-modules-cache-path setting).

Reviewers: teemperor, JDevlieghere

Subscribers: lldb-commits

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

llvm-svn: 370858

4 years ago[yaml2obj] Support PT_GNU_STACK and PT_GNU_RELRO
Fangrui Song [Wed, 4 Sep 2019 09:19:31 +0000 (09:19 +0000)]
[yaml2obj] Support PT_GNU_STACK and PT_GNU_RELRO

PT_GNU_STACK is used in an llvm-objcopy test.

I plan to use PT_GNU_RELRO in a patch to improve nested segment
processing in llvm-objcopy (PR42963).

Reviewed By: grimar

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

llvm-svn: 370857

4 years ago[lldb][NFC] Rename ReadRegisterValue to PrintRegisterValue
Raphael Isemann [Wed, 4 Sep 2019 09:18:10 +0000 (09:18 +0000)]
[lldb][NFC] Rename ReadRegisterValue to PrintRegisterValue

That was the actual name I had in mind, but it seems git didn't pick
that change up when committing my previous commit.

llvm-svn: 370856

4 years agoAdd .git-blame-ignore-revs file
Rui Ueyama [Wed, 4 Sep 2019 09:16:00 +0000 (09:16 +0000)]
Add .git-blame-ignore-revs file

This new file is intended to be used to list sweeping changes
such as mass reformatting or renaming. You can configure git-blame
so that the command ignores commits listed in this file.

The initial contents of this file is two commit hashes which did
mass renaming to the lld directory.

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

llvm-svn: 370855

4 years ago[lldb][NFC] Remove WriteRegister copy-pasta from ObjectFileMachO
Raphael Isemann [Wed, 4 Sep 2019 09:10:28 +0000 (09:10 +0000)]
[lldb][NFC] Remove WriteRegister copy-pasta from ObjectFileMachO

The function had the same name as one of the member function, so
it was just copied to all classes so that the lookup works. We
could also give the function a more better and unique name
(because it's actually printing the register value and writing
to the stream, not writing to the register).

Also removes the unused return value.

llvm-svn: 370854

4 years ago[ELF] Add a spell corrector for "undefined symbol" diagnostics
Fangrui Song [Wed, 4 Sep 2019 09:04:26 +0000 (09:04 +0000)]
[ELF] Add a spell corrector for "undefined symbol" diagnostics

Non-undefined symbols with Levenshtein distance 1 or a transposition are
suggestion candidates. This is probably good enough and it can suggest
some missing/superfluous qualifiers: const, restrict, volatile, & and &&
ref-qualifier, e.g.

   error: undefined symbol: foo(int*)
   >>> referenced by b.o:(.text+0x1)
  +>>> did you mean: foo(int const*)
  +>>> defined in: a.o

   error: undefined symbol: foo(int*&)
   >>> referenced by b.o:(.text+0x1)
  +>>> did you mean: foo(int*)
  +>>> defined in: b.o

Reviewed By: ruiu

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

llvm-svn: 370853

4 years ago[llvm-objcopy] Rename variable names "Section" to "Sec". NFC
Fangrui Song [Wed, 4 Sep 2019 08:43:27 +0000 (08:43 +0000)]
[llvm-objcopy] Rename variable names "Section" to "Sec". NFC

"Section" can refer to the type llvm::objcopy::elf::Section or the
variable name. Rename it to "Sec" for clarity. "Sec" is already used a
lot, so this change improves consistency as well.

Also change `auto` to `const SectionBase` for readability.

Reviewed By: grimar

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

llvm-svn: 370852

4 years ago[ARM][ParallelDSP] SExt mul for accumulation
Sam Parker [Wed, 4 Sep 2019 08:41:34 +0000 (08:41 +0000)]
[ARM][ParallelDSP] SExt mul for accumulation

For any unpaired muls, we accumulate them as an input to the
reduction. Check the type of the mul and perform a sext if the
existing accumlator input type is not the same.

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

llvm-svn: 370851

4 years agoRe-commit r363191 "[MS] Pretend constexpr variable template specializations are inline"
Hans Wennborg [Wed, 4 Sep 2019 08:19:30 +0000 (08:19 +0000)]
Re-commit r363191 "[MS] Pretend constexpr variable template specializations are inline"

While the next Visual Studio update (16.3) will fix this issue, that hasn't
shipped yet. Until then Clang wouldn't work with MSVC's headers which seems
unfortunate. Let's keep this in until VS 16.3 ships. (See also PR42843.)

> Fixes link errors with clang and the latest Visual C++ 14.21.27702
> headers, which was reported as PR42027.
>
> I chose to intentionally make these things linkonce_odr, i.e.
> discardable, so that we don't emit definitions of these things in every
> translation unit that includes STL headers.
>
> Note that this is *not* what MSVC does: MSVC has not yet implemented C++
> DR2387, so they emit fully specialized constexpr variable templates with
> static / internal linkage.
>
> Reviewers: rsmith
>
> Differential Revision: https://reviews.llvm.org/D63175

llvm-svn: 370850

4 years ago[IRPrinting] Improve module pass printer to work better with -filter-print-funcs
Taewook Oh [Wed, 4 Sep 2019 08:08:58 +0000 (08:08 +0000)]
[IRPrinting] Improve module pass printer to work better with -filter-print-funcs

Summary: Previously module pass printer pass prints the banner even when the module doesn't include any function provided with `-filter-print-funcs` option. This introduced a lot of noise, especailly with ThinLTO. This diff addresses the issue and makes the banner printed only when the module includes functions in `-filter-print-funcs` list.

Reviewers: fedor.sergeev

Subscribers: mehdi_amini, hiraditya, dexonsmith, llvm-commits

Tags: #llvm

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

llvm-svn: 370849

4 years ago[lldb][NFC] Add a simple test for thread_local storage.
Raphael Isemann [Wed, 4 Sep 2019 08:02:52 +0000 (08:02 +0000)]
[lldb][NFC] Add a simple test for thread_local storage.

Seems we fail to read TLS data on Linux, so the test only runs on
macOS for now. We will see how this test runs on the BSD bots.

llvm-svn: 370848

4 years ago[GlobalISel] Fix G_SEXT narrowScalar to bail out of unsupported type combination.
Amara Emerson [Wed, 4 Sep 2019 07:58:45 +0000 (07:58 +0000)]
[GlobalISel] Fix G_SEXT narrowScalar to bail out of unsupported type combination.

Similar to the issue with G_ZEXT that was fixed earlier, this is a quick
to fall back if the source type is not exactly half of the dest type.

Fixes the clang-cmake-aarch64-lld bot build.

llvm-svn: 370847

4 years ago[dotest] Avoid the need for LEVEL= makefile boilerplate
Pavel Labath [Wed, 4 Sep 2019 07:46:25 +0000 (07:46 +0000)]
[dotest] Avoid the need for LEVEL= makefile boilerplate

Summary:
Instead of each test case knowing its depth relative to the test root,
we can just have dotest add the folder containing Makefile.rules to the
include path.

This was motivated by r370616, though I have been wanting to do this
ever since we moved to building tests out-of-tree.

The only manually modified files in this patch are lldbinline.py and
plugins/builder_base.py. The rest of the patch has been produced by this
shell command:
  find . \( -name Makefile -o -name '*.mk' \)  -exec sed --in-place -e '/LEVEL *:\?=/d' -e '1,2{/^$/d}' -e 's,\$(LEVEL)/,,' {} +

Reviewers: teemperor, aprantl, espindola, jfb

Subscribers: emaste, javed.absar, arichardson, christof, arphaman, lldb-commits

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

llvm-svn: 370845

4 years agogn build: Merge r370843
Nico Weber [Wed, 4 Sep 2019 07:40:03 +0000 (07:40 +0000)]
gn build: Merge r370843

llvm-svn: 370844

4 years ago[clangd] Split Preamble.h out of ClangdUnit.h. NFC
Sam McCall [Wed, 4 Sep 2019 07:35:00 +0000 (07:35 +0000)]
[clangd] Split Preamble.h out of ClangdUnit.h. NFC

Summary:
Add comment describing use of preamble in clangd.
Remove deps on ClangdUnit.h where possible.

Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 370843

4 years ago[lldb] [test] Mark 'reenabled' tests XFAIL on NetBSD
Michal Gorny [Wed, 4 Sep 2019 06:36:53 +0000 (06:36 +0000)]
[lldb] [test] Mark 'reenabled' tests XFAIL on NetBSD

llvm-svn: 370842

4 years agoAdd a newline at the end of the file
Rui Ueyama [Wed, 4 Sep 2019 06:33:46 +0000 (06:33 +0000)]
Add a newline at the end of the file

llvm-svn: 370841

4 years ago[lldb] [test] Un-mark two commands/register tests XFAIL
Michal Gorny [Wed, 4 Sep 2019 06:10:02 +0000 (06:10 +0000)]
[lldb] [test] Un-mark two commands/register tests XFAIL

llvm-svn: 370840

4 years ago[Clang Interpreter] Initial patch for the constexpr interpreter
Nandor Licker [Wed, 4 Sep 2019 05:49:41 +0000 (05:49 +0000)]
[Clang Interpreter] Initial patch for the constexpr interpreter

Summary:
This patch introduces the skeleton of the constexpr interpreter,
capable of evaluating a simple constexpr functions consisting of
if statements. The interpreter is described in more detail in the
RFC. Further patches will add more features.

Reviewers: Bigcheese, jfb, rsmith

Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits

Tags: #clang

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

llvm-svn: 370839

4 years ago[llvm-objcopy] Fix some identifier names in comments. NFC
Fangrui Song [Wed, 4 Sep 2019 03:54:43 +0000 (03:54 +0000)]
[llvm-objcopy] Fix some identifier names in comments. NFC

llvm-svn: 370838

4 years ago[RISCV] Enable tail call opt for variadic function
Jim Lin [Wed, 4 Sep 2019 02:03:36 +0000 (02:03 +0000)]
[RISCV] Enable tail call opt for variadic function

Summary: Tail call opt can treat variadic function call the same as normal function call

Reviewers: mgrang, asb, lenary, lewis-revill

Reviewed By: lenary

Subscribers: luismarques, pzheng, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, s.egerton, llvm-commits

Tags: #llvm

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

llvm-svn: 370835

4 years ago[MemorySSA] Move two verify calls under expensive checks.
Alina Sbirlea [Wed, 4 Sep 2019 00:44:54 +0000 (00:44 +0000)]
[MemorySSA] Move two verify calls under expensive checks.

llvm-svn: 370831

4 years ago[NFC][llvm-ifs] Adding .ifs files to the test list for llvm-ifs tool.
Puyan Lotfi [Wed, 4 Sep 2019 00:07:49 +0000 (00:07 +0000)]
[NFC][llvm-ifs] Adding .ifs files to the test list for llvm-ifs tool.

llvm-svn: 370830

4 years agoRevert [Windows] Disable TrapUnreachable for Win64, add SEH_NoReturn
Reid Kleckner [Tue, 3 Sep 2019 22:27:27 +0000 (22:27 +0000)]
Revert [Windows] Disable TrapUnreachable for Win64, add SEH_NoReturn

This reverts r370525 (git commit 0bb1630685fba255fa93def92603f064c2ffd203)
Also reverts r370543 (git commit 185ddc08eed6542781040b8499ef7ad15c8ae9f4)

The approach I took only works for functions marked `noreturn`. In
general, a call that is not known to be noreturn may be followed by
unreachable for other reasons. For example, there could be multiple call
sites to a function that throws sometimes, and at some call sites, it is
known to always throw, so it is followed by unreachable. We need to
insert an `int3` in these cases to pacify the Windows unwinder.

I think this probably deserves its own standalone, Win64-only fixup pass
that runs after block placement. Implementing that will take some time,
so let's revert to TrapUnreachable in the mean time.

llvm-svn: 370829

4 years ago[WebAssembly] Compare functions by names in Emscripten Sjlj
Heejin Ahn [Tue, 3 Sep 2019 22:26:49 +0000 (22:26 +0000)]
[WebAssembly] Compare functions by names in Emscripten Sjlj

Summary:
This removes all string constants for function names and compares
functions by string directly when needed. Many of these constants are
used only once or twice so the benefit of defining them separately is
not very clear, and this actually fixes a bug.

When we already have a `malloc` declaration which is an alias to
something else within the module,
```
@malloc = weak hidden alias i8* (i32), i8* (i32)* @dlmalloc
```
(this happens compiling with emscripten with `-s WASM_OBJECT_FILES=0`
because all bc files are merged before being fed into `wasm-ld` which
runs the backend optimizations as LTO)

`Module::getFunction("malloc")` in `canLongjmp` returns `nullptr`
because `Module::getFunction` dyncasts pointer into `Function`, but the
alias is a `GlobalValue` but not a `Function`. This makes `canLongjmp`
return false for `malloc` in this case, and we end up adding a lot of
longjmp handling code around malloc. This is not only a code size
increase but actually a bug because `malloc` is used in the entry block
when preparing for setjmp tables for emscripten sjlj handling, and this
makes initial setjmp preparation, which has to happen in the entry
block, move to another split block, and this interferes with SSA update
later.

This also adds two more functions, `getTempRet0` and `setTempRet0`, in
the list of not longjmp-able functions.

Fixes https://github.com/emscripten-core/emscripten/issues/8935.

Reviewers: sbc100

Subscribers: mehdi_amini, jgravelle-google, hiraditya, sunfish, dexonsmith, dschuff, llvm-commits

Tags: #llvm

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

llvm-svn: 370828

4 years ago[llvm-profdata] Add mode to recover from profile read failures
Vedant Kumar [Tue, 3 Sep 2019 22:23:16 +0000 (22:23 +0000)]
[llvm-profdata] Add mode to recover from profile read failures

Add a mode in which profile read errors are not immediately treated as
fatal. In this mode, merging makes forward progress and reports failure
only if no inputs can be read.

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

llvm-svn: 370827

4 years ago[InstrProf] Tighten a check for malformed data records in raw profiles
Vedant Kumar [Tue, 3 Sep 2019 22:23:14 +0000 (22:23 +0000)]
[InstrProf] Tighten a check for malformed data records in raw profiles

The check needs to validate a counter offset before performing pointer
arithmetic with the (potentially corrupt) offset.

Found by UBSan's pointer overflow check.

rdar://54843625

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

llvm-svn: 370826

4 years ago[libclang][test][NFC] Split off fixture from tests.
Jan Korous [Tue, 3 Sep 2019 22:01:46 +0000 (22:01 +0000)]
[libclang][test][NFC] Split off fixture from tests.

llvm-svn: 370825

4 years ago[GVN] Remove a todo introduced w/rL370791
Philip Reames [Tue, 3 Sep 2019 21:56:17 +0000 (21:56 +0000)]
[GVN] Remove a todo introduced w/rL370791

When I dug into this, it turns out to be *much* more involved than I'd realized and doesn't actually simplify anything.

The general purpose of the leader table is that we want to find the most-dominating definition quickly.  The problem for equivalance folding is slightly different; we want to find the most dominating *value* whose definition block dominates our use quickly.

To make this change, we'd end up having to restructure the leader table (either the sorting thereof, or maybe even introducing multiple leader tables per value) and that complexity is just not worth it.

llvm-svn: 370824

4 years ago[AArch64][GlobalISel] Legalize 128 bit divisions to libcalls.
Amara Emerson [Tue, 3 Sep 2019 21:42:32 +0000 (21:42 +0000)]
[AArch64][GlobalISel] Legalize 128 bit divisions to libcalls.

Now that we have the infrastructure to support s128 types as parameters
we can expand these to libcalls.

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

llvm-svn: 370823

4 years ago[GlobalISel][CallLowering] Add support for splitting types according to calling conve...
Amara Emerson [Tue, 3 Sep 2019 21:42:28 +0000 (21:42 +0000)]
[GlobalISel][CallLowering] Add support for splitting types according to calling conventions.

On AArch64, s128 types have to be split into s64 GPRs when passed as arguments.
This change adds the generic support in call lowering for dealing with multiple
registers, for incoming and outgoing args.

Support for splitting for return types not yet implemented.

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

llvm-svn: 370822

4 years ago[MemorySSA] Disable MemorySSA use.
Alina Sbirlea [Tue, 3 Sep 2019 21:20:46 +0000 (21:20 +0000)]
[MemorySSA] Disable MemorySSA use.

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

llvm-svn: 370821

4 years ago[Attributor] Use the delete API for liveness
Johannes Doerfert [Tue, 3 Sep 2019 20:42:16 +0000 (20:42 +0000)]
[Attributor] Use the delete API for liveness

Reviewers: uenoku, sstefan1

Subscribers: hiraditya, bollu, llvm-commits

Tags: #llvm

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

llvm-svn: 370818

4 years ago[Attributor] Deduce "no-capture" argument attribute
Johannes Doerfert [Tue, 3 Sep 2019 20:37:24 +0000 (20:37 +0000)]
[Attributor] Deduce "no-capture" argument attribute

Add the no-capture argument attribute deduction to the Attributor
fixpoint framework.

The new string attributed "no-capture-maybe-returned" is introduced to
allow deduction of no-capture through functions that "capture" an
argument but only by "returning" it. It is only used by the Attributor
for testing.

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

llvm-svn: 370817

4 years agoreland "[lld-link] implement -start-lib and -end-lib"
Bob Haarman [Tue, 3 Sep 2019 20:32:16 +0000 (20:32 +0000)]
reland "[lld-link] implement -start-lib and -end-lib"

Summary:
This is a re-land of r370487 with a fix for the use-after-free bug
that rev contained.

This implements -start-lib and -end-lib flags for lld-link, analogous
to the similarly named options in ld.lld. Object files after
-start-lib are included in the link only when needed to resolve
undefined symbols. The -end-lib flag goes back to the normal behavior
of always including object files in the link. This mimics the
semantics of static libraries, but without needing to actually create
the archive file.

Reviewers: ruiu, smeenai, MaskRay

Reviewed By: ruiu, MaskRay

Subscribers: akhuang, llvm-commits

Tags: #llvm

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

llvm-svn: 370816

4 years ago[Driver] Remove duplicate option parsing (NFC)
Jonas Devlieghere [Tue, 3 Sep 2019 20:18:19 +0000 (20:18 +0000)]
[Driver] Remove duplicate option parsing (NFC)

We were checking OPT_no_use_colors three times, twice to disable colors
and once to enable debug mode. This simplifies things and now the option
is only checked once.

llvm-svn: 370814

4 years ago[CodeGen] Use FSHR in DAGTypeLegalizer::ExpandIntRes_MULFIX
Bjorn Pettersson [Tue, 3 Sep 2019 19:35:07 +0000 (19:35 +0000)]
[CodeGen] Use FSHR in DAGTypeLegalizer::ExpandIntRes_MULFIX

Summary:
Simplify the right shift of the intermediate result (given
in four parts) by using funnel shift.

There are some impact on lit tests, but that seems to be
related to register allocation differences due to how FSHR
is expanded on X86 (giving a slightly different operand order
for the OR operations compared to the old code).

Reviewers: leonardchan, RKSimon, spatel, lebedev.ri

Reviewed By: RKSimon

Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, s.egerton, pzheng, bevinh, llvm-commits

Tags: #llvm

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

llvm-svn: 370813

4 years agoSkip MCJIT unit tests if LLVM is not configured for native compilation
David Blaikie [Tue, 3 Sep 2019 19:30:45 +0000 (19:30 +0000)]
Skip MCJIT unit tests if LLVM is not configured for native compilation

Patch by Sergej Jaskiewicz!

Differential Revision: D67089

llvm-svn: 370812

4 years ago[MemorySSA] Re-enable MemorySSA use.
Alina Sbirlea [Tue, 3 Sep 2019 19:28:37 +0000 (19:28 +0000)]
[MemorySSA] Re-enable MemorySSA use.

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

llvm-svn: 370811

4 years ago[AMDGPU] Set default flat work group size to (1,256) for HIP
Yaxun Liu [Tue, 3 Sep 2019 18:50:24 +0000 (18:50 +0000)]
[AMDGPU] Set default flat work group size to (1,256) for HIP

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

llvm-svn: 370808

4 years agoUnbreak the build after r370798
Benjamin Kramer [Tue, 3 Sep 2019 18:24:56 +0000 (18:24 +0000)]
Unbreak the build after r370798

llvm-svn: 370807

4 years ago[MC] Pass through .code16/32/64 and .syntax unified for COFF
Reid Kleckner [Tue, 3 Sep 2019 18:16:52 +0000 (18:16 +0000)]
[MC] Pass through .code16/32/64 and .syntax unified for COFF

These flags should simply be passed through to the target, which will do
the right thing. Add an MC/X86 test that uses these directives with the
three primary object file formats and shows that they disassemble the
same everywhere.

There is a missing test for .code32 on Windows ARM, since I'm not sure
exactly how to construct one.

Fixes PR43203

llvm-svn: 370805

4 years ago[lldb][NFC] Remove lldbcurses.py
Raphael Isemann [Tue, 3 Sep 2019 18:11:54 +0000 (18:11 +0000)]
[lldb][NFC] Remove lldbcurses.py

Summary: This doesn't seem to be used anymore (at least I can't find any reference to this in the LLDB repo and it doesn't seem to be a standalone script). Git says this was once some new curses mode for viewing test results.

Reviewers: clayborg, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 370804

4 years ago[OPENMP][NVPTX]Fix parallel level counter in non-SPMD mode.
Alexey Bataev [Tue, 3 Sep 2019 18:11:50 +0000 (18:11 +0000)]
[OPENMP][NVPTX]Fix parallel level counter in non-SPMD mode.

Summary:
In non-SPMD mode we may end up with the divergent threads when trying to
increment/decrement parallel level counter. It may lead to incorrect
calculations of the parallel level and wrong results when threads are
divergent. We need to reconverge the threads before trying to modify the
parallel level counter.

Reviewers: grokos, jdoerfert

Subscribers: guansong, openmp-commits, caomhin, kkwli0

Tags: #openmp

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

llvm-svn: 370803

4 years ago[lldb][NFC] Remove unused overload of File::Read
Raphael Isemann [Tue, 3 Sep 2019 18:11:14 +0000 (18:11 +0000)]
[lldb][NFC] Remove unused overload of File::Read

Summary: It's neither used or tested here and in swift-lldb, so let's get rid of it.

Reviewers: #lldb, davide

Reviewed By: #lldb, davide

Subscribers: davide, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 370802

4 years agoDisable stack exhaustion test on NetBSD, where either the detection or
Richard Smith [Tue, 3 Sep 2019 18:00:44 +0000 (18:00 +0000)]
Disable stack exhaustion test on NetBSD, where either the detection or
recovery mechanism does not appear to work.

llvm-svn: 370801

4 years agold.lld.1: explain long options may use one or two dashes
Ed Maste [Tue, 3 Sep 2019 17:58:30 +0000 (17:58 +0000)]
ld.lld.1: explain long options may use one or two dashes

Obtained from FreeBSD r329003

llvm-svn: 370800

4 years agold.lld.1: stylistic changes suggested by igor
Ed Maste [Tue, 3 Sep 2019 17:58:24 +0000 (17:58 +0000)]
ld.lld.1: stylistic changes suggested by igor

igor is an automated man page "proofreader" from FreeBSD - see
http://www.wonkity.com/~wblock/igor/igor.pdf

No content change.

llvm-svn: 370799

4 years ago[analyzer] NonNullParamChecker and CStringChecker parameter number in checker message
Kristof Umann [Tue, 3 Sep 2019 17:57:01 +0000 (17:57 +0000)]
[analyzer] NonNullParamChecker and CStringChecker parameter number in checker message

There are some functions which can't be given a null pointer as parameter either
because it has a nonnull attribute or it is declared to have undefined behavior
(e.g. strcmp()). Sometimes it is hard to determine from the checker message
which parameter is null at the invocation, so now this information is included
in the message.

This commit fixes https://bugs.llvm.org/show_bug.cgi?id=39358

Reviewed By: NoQ, Szelethus, whisperity

Patch by Tibor Brunner!

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

llvm-svn: 370798

4 years ago[libc++] Mark usage of _Atomic with __extension__
Louis Dionne [Tue, 3 Sep 2019 17:52:18 +0000 (17:52 +0000)]
[libc++] Mark usage of _Atomic with __extension__

An upcoming change in Clang will flag _Atomic as being a C11 extension.
To avoid generating this warning in libc++, this commit marks the only
use of _Atomic with the __extension__ extension, which suppresses such
warnings.

llvm-svn: 370796

4 years ago[www] Mark items complete in Clang 9 as 'Clang 9' rather than 'SVN'.
Richard Smith [Tue, 3 Sep 2019 17:49:51 +0000 (17:49 +0000)]
[www] Mark items complete in Clang 9 as 'Clang 9' rather than 'SVN'.

Don't turn the boxes green yet, since Clang 9 hasn't been released.

llvm-svn: 370795

4 years ago[CUDA] Use activemask.b32 instruction to implement __activemask w/ CUDA-9.2+
Artem Belevich [Tue, 3 Sep 2019 17:31:58 +0000 (17:31 +0000)]
[CUDA] Use activemask.b32 instruction to implement __activemask w/ CUDA-9.2+

vote.ballot instruction is gone in recent CUDA versions and
vote.sync.ballot can not be used because it needs a thread mask parameter.
Fortunately PTX 6.2 (introduced with CUDA-9.2) provides activemask.b32
instruction for this.

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

llvm-svn: 370792

4 years ago[GVN] Propagate simple equalities from assumes within the tail of the block
Philip Reames [Tue, 3 Sep 2019 17:31:19 +0000 (17:31 +0000)]
[GVN] Propagate simple equalities from assumes within the tail of the block

This extends the existing logic for propagating constant expressions in an analogous manner for what we do across basic blocks. The core point is that we chose some order of operands, and canonicalize uses towards that one.

The heuristic used is inspired by the one used across blocks; in a follow up change, I'd plan to common them so that the cross block version uses the slightly stronger ordering herein.

As noted by the TODOs in the code, there's a good amount of room for improving the existing code and making it more powerful.  Some follow up work planned.

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

llvm-svn: 370791

4 years ago[AArch64][GlobalISel] Don't import i64imm_32bit pattern at -O0
Jessica Paquette [Tue, 3 Sep 2019 17:21:12 +0000 (17:21 +0000)]
[AArch64][GlobalISel] Don't import i64imm_32bit pattern at -O0

This pattern, when imported at -O0 adds an extra copy via the SUBREG_TO_REG.

This is because the SUBREG_TO_REG is not eliminated. At all other opt levels,
it is eliminated.

This is a 1% geomean code size savings at -O0 on CTMark.

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

llvm-svn: 370789

4 years agoRevert r370454 "[LoopIdiomRecognize] BCmp loop idiom recognition"
Roman Lebedev [Tue, 3 Sep 2019 17:14:56 +0000 (17:14 +0000)]
Revert r370454 "[LoopIdiomRecognize] BCmp loop idiom recognition"

https://bugs.llvm.org/show_bug.cgi?id=43206 was filed,
claiming that there is a miscompilation.
Reverting until i investigate.

This reverts commit r370454

llvm-svn: 370788

4 years ago[test] Addres TestConcurrentMany*.py flakiness on macOS
Jonas Devlieghere [Tue, 3 Sep 2019 17:04:04 +0000 (17:04 +0000)]
[test] Addres  TestConcurrentMany*.py flakiness on macOS

On "fast" macOS machines, the TestConcurrentMany*.py tests would fail
randomly with different numbers of breakpoints, watchpoints, etc. This
seems to be avoidable by giving the threads a little time to breath
after the passing the synchronization barrier. This is far from a
structural fix but it reduces the flakiness.

llvm-svn: 370785

4 years ago[Tests/GVN] Precommit requested test additions from D66977
Philip Reames [Tue, 3 Sep 2019 17:02:55 +0000 (17:02 +0000)]
[Tests/GVN] Precommit requested test additions from D66977

llvm-svn: 370784

4 years ago[libomptarget] Refactor activemask macro to inline function
Jon Chesterfield [Tue, 3 Sep 2019 16:31:30 +0000 (16:31 +0000)]
[libomptarget] Refactor activemask macro to inline function

Summary:
[libomptarget] Refactor activemask macro to inline function
See also abandoned D66846, split into this diff and others.

Reviewers: jdoerfert, ABataev, grokos, ronlieb, gregrodgers

Reviewed By: jdoerfert, ABataev

Subscribers: openmp-commits

Tags: #openmp

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

llvm-svn: 370781

4 years agoclang: default to DWARF 4 for FreeBSD 12.0 and later
Ed Maste [Tue, 3 Sep 2019 16:30:21 +0000 (16:30 +0000)]
clang: default to DWARF 4 for FreeBSD 12.0 and later

Older FreeBSD versions included GDB 6.1 and had other tools that were
unable to handle debug information newer than DWARF 2.  Those tools have
since been updated.  (An old version of GDB is still kept for kernel
crash handling, but the kernel is compiled with an explicit -gdwarf2.)

Reviewed by: dim
Differential Revision: https://reviews.llvm.org/D66760

llvm-svn: 370779

4 years ago[test] Remove print statements and verify that the symbol exists
Jonas Devlieghere [Tue, 3 Sep 2019 16:26:44 +0000 (16:26 +0000)]
[test] Remove print statements and verify that the symbol exists

This removes some (commented out) print statements and adds a line that
verifies that uses image list to check the symbol.

llvm-svn: 370777

4 years ago[lldb][NFC] Disable added frame select and all log option test on windows
Raphael Isemann [Tue, 3 Sep 2019 16:21:57 +0000 (16:21 +0000)]
[lldb][NFC] Disable added frame select and all log option test on windows

llvm-svn: 370776

4 years ago[LifetimeAnalysis] Fix some false positives
Gabor Horvath [Tue, 3 Sep 2019 16:17:24 +0000 (16:17 +0000)]
[LifetimeAnalysis] Fix some false positives

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

llvm-svn: 370773

4 years ago[cmake] Improve comment describing the C4245 warning. NFCI.
Simon Pilgrim [Tue, 3 Sep 2019 16:11:37 +0000 (16:11 +0000)]
[cmake] Improve comment describing the C4245 warning. NFCI.

llvm-svn: 370772

4 years ago[SVE][Inline-Asm] Fix -Wimplicit-fallthrough in AArch64ISelLowering.cpp
Kerry McLaughlin [Tue, 3 Sep 2019 15:45:42 +0000 (15:45 +0000)]
[SVE][Inline-Asm] Fix -Wimplicit-fallthrough in AArch64ISelLowering.cpp

Summary: Adds break to 'x' case in getRegForInlineAsmConstraint added by D66302, fixing the unintentional fallthrough.

Reviewers: sdesmalen, rovka, cameron.mcinally, greened, gribozavr, ruiu

Reviewed By: sdesmalen

Subscribers: bjope, javed.absar, tschuett, kristof.beyls, rkruppe, psnobl, llvm-commits, cfe-commits

Tags: #llvm

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

llvm-svn: 370769

4 years ago[clangd] Move getBeginningOfIdentifier from ClangdUnit to SourceCode. Drop dependenci...
Sam McCall [Tue, 3 Sep 2019 15:34:47 +0000 (15:34 +0000)]
[clangd] Move getBeginningOfIdentifier from ClangdUnit to SourceCode. Drop dependencies on ClangdUnit from some headers. NFC

llvm-svn: 370768

4 years ago[analyzer] Add a checker option to detect nested dead stores
Kristof Umann [Tue, 3 Sep 2019 15:22:43 +0000 (15:22 +0000)]
[analyzer] Add a checker option to detect nested dead stores

Enables the users to specify an optional flag which would warn for more dead
stores.
Previously it ignored if the dead store happened e.g. in an if condition.

if ((X = generate())) { // dead store to X
}

This patch introduces the `WarnForDeadNestedAssignments` option to the checker,
which is `false` by default - so this change would not affect any previous
users.
I have updated the code, tests and the docs as well. If I missed something, tell
me.

I also ran the analysis on Clang which generated 14 more reports compared to the
unmodified version. All of them seemed reasonable for me.

Related previous patches:
rGf224820b45c6847b91071da8d7ade59f373b96f3

Reviewers: NoQ, krememek, Szelethus, baloghadamsoftware

Reviewed By: Szelethus

Patch by Balázs Benics!

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

llvm-svn: 370767

4 years ago[clangd] Remove redundant semi-colon.
Michael Liao [Tue, 3 Sep 2019 15:02:46 +0000 (15:02 +0000)]
[clangd] Remove redundant semi-colon.

llvm-svn: 370763

4 years ago[X86] Merge 2 consecutive HasInt256 branches. NFCI.
Simon Pilgrim [Tue, 3 Sep 2019 14:39:06 +0000 (14:39 +0000)]
[X86] Merge 2 consecutive HasInt256 branches. NFCI.

llvm-svn: 370761

4 years ago[clang-tidy] Fix a false positive in unused-using-decl check
Haojian Wu [Tue, 3 Sep 2019 14:13:00 +0000 (14:13 +0000)]
[clang-tidy] Fix a false positive in unused-using-decl check

The previous matcher "hasAnyTemplateArgument(templateArgument())" only
matches the first template argument, but the check wants to iterate all
template arguments. This patch fixes this.

Also some refactorings in this patch (to make the code reusable).

llvm-svn: 370760

4 years ago[clangd] Decouple macro/decl-under-cursor finding. Don't pretend there can be multipl...
Sam McCall [Tue, 3 Sep 2019 14:12:48 +0000 (14:12 +0000)]
[clangd] Decouple macro/decl-under-cursor finding. Don't pretend there can be multiple macros. NFC.

llvm-svn: 370759