platform/upstream/llvm.git
5 years ago[gn build] Add build files for opt and its dependency Transforms/Couroutines
Nico Weber [Mon, 17 Dec 2018 02:33:15 +0000 (02:33 +0000)]
[gn build] Add build files for opt and its dependency Transforms/Couroutines

Needed for check-lld.

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

llvm-svn: 349324

5 years ago[EarlyCSE] If DI can't be salvaged, mark it as unavailable.
Davide Italiano [Mon, 17 Dec 2018 01:42:39 +0000 (01:42 +0000)]
[EarlyCSE] If DI can't be salvaged, mark it as unavailable.

Fixes PR39874.

llvm-svn: 349323

5 years ago[InstCombine] Add cttz/ctlz + select non-bitwidth tests; NFC
Nikita Popov [Sun, 16 Dec 2018 23:48:18 +0000 (23:48 +0000)]
[InstCombine] Add cttz/ctlz + select non-bitwidth tests; NFC

llvm-svn: 349322

5 years ago[InstCombine] Regenerate test checks; NFC
Nikita Popov [Sun, 16 Dec 2018 23:48:11 +0000 (23:48 +0000)]
[InstCombine] Regenerate test checks; NFC

Also drop unnecessary entry blocks and avoid use of anonymous
variables.

llvm-svn: 349321

5 years ago[analyzer] Fix some expressions staying live too long. Add a debug checker.
Artem Dergachev [Sun, 16 Dec 2018 23:44:06 +0000 (23:44 +0000)]
[analyzer] Fix some expressions staying live too long. Add a debug checker.

StaticAnalyzer uses the CFG-based RelaxedLiveVariables analysis in order to,
in particular, figure out values of which expressions are still needed.
When the expression becomes "dead", it is garbage-collected during
the dead binding scan.

Expressions that constitute branches/bodies of control flow statements,
eg. `E1' in `if (C1) E1;' but not `E2' in `if (C2) { E2; }', were kept alive
for too long. This caused false positives in MoveChecker because it relies
on cleaning up loop-local variables when they go out of scope, but some of those
live-for-too-long expressions were keeping a reference to those variables.

Fix liveness analysis to correctly mark these expressions as dead.

Add a debug checker, debug.DumpLiveStmts, in order to test expressions liveness.

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

llvm-svn: 349320

5 years ago[X86] Pull out constant splat rotation detection.
Simon Pilgrim [Sun, 16 Dec 2018 19:46:04 +0000 (19:46 +0000)]
[X86] Pull out constant splat rotation detection.

We had 3 different approaches - consistently use getTargetConstantBitsFromNode and allow undef elts.

llvm-svn: 349319

5 years ago[InstCombine] Make cttz/ctlz knownbits tests more robust; NFC
Nikita Popov [Sun, 16 Dec 2018 19:12:08 +0000 (19:12 +0000)]
[InstCombine] Make cttz/ctlz knownbits tests more robust; NFC

Tests checking for the addition of !range metadata should be
preserved if cttz/ctlz + icmp is optimized.

llvm-svn: 349318

5 years agoRegenerate test (merges X86+X64 cases). NFCI.
Simon Pilgrim [Sun, 16 Dec 2018 19:07:57 +0000 (19:07 +0000)]
Regenerate test (merges X86+X64 cases). NFCI.

llvm-svn: 349317

5 years agoAdd a description of the similar packets defined in the
Jason Molenda [Sun, 16 Dec 2018 18:44:54 +0000 (18:44 +0000)]
Add a description of the similar packets defined in the
gdb-remote serial protocol documentation, call out the
incompatability of lldb's vFile:open: packet as it stands
today.  Need to think about whether to change lldb's
enum values (breaking any existing lldb-server's out there)
or create a different packet and abandon vFile:open: at
least for a while.

llvm-svn: 349316

5 years ago[X86] Remove truncation handling from EmitTest. Replace it with a DAG combine.
Craig Topper [Sun, 16 Dec 2018 18:35:55 +0000 (18:35 +0000)]
[X86] Remove truncation handling from EmitTest. Replace it with a DAG combine.

I'd like to try to move a lot of the flag matching out of EmitTest and push it to isel or isel preprocessing. This is a step towards that.

The test-shrink-bug.ll changie is an improvement because we are no longer interfering with test shrink handling in isel.

The pr34137.ll change is a regression, but the IR came from -O0 and was not reduced by InstCombine. So it contains a lot of redundancies like duplicate loads that made it combine poorly.

llvm-svn: 349315

5 years ago[X86] Autogenerate complete checks. NFC
Craig Topper [Sun, 16 Dec 2018 18:35:54 +0000 (18:35 +0000)]
[X86] Autogenerate complete checks. NFC

llvm-svn: 349314

5 years agoClarify a few minor details.
Jason Molenda [Sun, 16 Dec 2018 18:33:58 +0000 (18:33 +0000)]
Clarify a few minor details.

llvm-svn: 349313

5 years agoRevert "[InstCombine] Regenerate test checks; NFC"
Nikita Popov [Sun, 16 Dec 2018 18:27:37 +0000 (18:27 +0000)]
Revert "[InstCombine] Regenerate test checks; NFC"

This reverts commit r349311.

Didn't check this carefully enough...

llvm-svn: 349312

5 years ago[InstCombine] Regenerate test checks; NFC
Nikita Popov [Sun, 16 Dec 2018 18:22:57 +0000 (18:22 +0000)]
[InstCombine] Regenerate test checks; NFC

llvm-svn: 349311

5 years ago[InstCombined] Add more tests for cttz/ctlz + icmp; NFC
Nikita Popov [Sun, 16 Dec 2018 17:51:32 +0000 (17:51 +0000)]
[InstCombined] Add more tests for cttz/ctlz + icmp; NFC

Test cases other than icmp with the bitwidth.

llvm-svn: 349310

5 years ago[InstCombine] Add additional saturating add/sub + icmp tests; NFC
Nikita Popov [Sun, 16 Dec 2018 17:45:25 +0000 (17:45 +0000)]
[InstCombine] Add additional saturating add/sub + icmp tests; NFC

These test comparisons with saturating add/sub in non-canonical
form.

llvm-svn: 349309

5 years agoThread safety analysis: Avoid intermediate copies [NFC]
Aaron Puchert [Sun, 16 Dec 2018 16:19:11 +0000 (16:19 +0000)]
Thread safety analysis: Avoid intermediate copies [NFC]

The main reason is to reduce the number of constructor arguments though,
especially since many of them had the same type.

llvm-svn: 349308

5 years ago[InstCombine] regenerate test checks; NFC
Sanjay Patel [Sun, 16 Dec 2018 16:14:42 +0000 (16:14 +0000)]
[InstCombine] regenerate test checks; NFC

llvm-svn: 349307

5 years ago[InstCombine] add tests for vector widening transforms (PR40032); NFC
Sanjay Patel [Sun, 16 Dec 2018 15:50:50 +0000 (15:50 +0000)]
[InstCombine] add tests for vector widening transforms (PR40032); NFC

llvm-svn: 349306

5 years ago[test] [support] Use socket()+bind() to create unix sockets portably
Michal Gorny [Sun, 16 Dec 2018 15:12:06 +0000 (15:12 +0000)]
[test] [support] Use socket()+bind() to create unix sockets portably

Replace the mknod() call with socket() + bind() for creating unix
sockets.  The mknod() method is not portable and does not work
on NetBSD while binding the socket should work on all systems supporting
unix sockets.

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

llvm-svn: 349305

5 years ago[x86] increment/decrement constant vector with min/max in vsetcc lowering (PR39859)
Sanjay Patel [Sun, 16 Dec 2018 15:05:48 +0000 (15:05 +0000)]
[x86] increment/decrement constant vector with min/max in vsetcc lowering (PR39859)

This is part of fixing PR39859:
https://bugs.llvm.org/show_bug.cgi?id=39859

We have a crippled vector ISA, so we have to invert a typical fold and create min/max here.

As discussed in the bug report, we can probably do better by using saturating subtract when
it's available, but we should have this improvement for the min/max patterns regardless.

Alive proofs:
https://rise4fun.com/Alive/zsf
https://rise4fun.com/Alive/Qrl

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

llvm-svn: 349304

5 years ago[DAGCombiner] allow hoisting vector bitwise logic ahead of truncates
Sanjay Patel [Sun, 16 Dec 2018 14:57:04 +0000 (14:57 +0000)]
[DAGCombiner] allow hoisting vector bitwise logic ahead of truncates

The transform performs a bitwise logic op in a wider type followed by
truncate when both inputs are truncated from the same source type:
logic_op (truncate x), (truncate y) --> truncate (logic_op x, y)

There are a bunch of other checks that should prevent doing this when
it might be harmful.

We already do this transform for scalars in this spot. The vector
limitation was shared with a check for the case when the operands are
extended. I'm not sure if that limit is needed either, but that would
be a separate patch.

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

llvm-svn: 349303

5 years agoUpdate the list of platforms & archs
Sylvestre Ledru [Sun, 16 Dec 2018 14:47:16 +0000 (14:47 +0000)]
Update the list of platforms & archs

llvm-svn: 349302

5 years agoUse backquotes to avoid a sphinx unexpected error:
Sylvestre Ledru [Sun, 16 Dec 2018 14:19:39 +0000 (14:19 +0000)]
Use backquotes to avoid a sphinx unexpected error:
Unknown target name: "bootstrap".

llvm-svn: 349301

5 years agoThread safety analysis: Allow scoped releasing of capabilities
Aaron Puchert [Sun, 16 Dec 2018 14:15:30 +0000 (14:15 +0000)]
Thread safety analysis: Allow scoped releasing of capabilities

Summary:
The pattern is problematic with C++ exceptions, and not as widespread as
scoped locks, but it's still used by some, for example Chromium.

We are a bit stricter here at join points, patterns that are allowed for
scoped locks aren't allowed here. That could still be changed in the
future, but I'd argue we should only relax this if people ask for it.

Fixes PR36162.

Reviewers: aaron.ballman, delesley, pwnall

Reviewed By: delesley, pwnall

Subscribers: pwnall, cfe-commits

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

llvm-svn: 349300

5 years agoDocument the usage of BOOTSTRAP_XXX with stage2 builds
Sylvestre Ledru [Sun, 16 Dec 2018 14:04:10 +0000 (14:04 +0000)]
Document the usage of BOOTSTRAP_XXX with stage2 builds

llvm-svn: 349299

5 years ago[SelectionDAG] Add FSHL/FSHR support to computeKnownBits
Simon Pilgrim [Sun, 16 Dec 2018 13:33:37 +0000 (13:33 +0000)]
[SelectionDAG] Add FSHL/FSHR support to computeKnownBits

Also exposes an issue in DAGCombiner::visitFunnelShift where we were assuming the shift amount had the result type (after legalization it'll have the targets shift amount type).

llvm-svn: 349298

5 years ago[X86] Add computeKnownBits tests for funnel shift intrinsics
Simon Pilgrim [Sun, 16 Dec 2018 12:15:31 +0000 (12:15 +0000)]
[X86] Add computeKnownBits tests for funnel shift intrinsics

llvm-svn: 349297

5 years agoImprove the comment in previous
Kamil Rytarowski [Sun, 16 Dec 2018 10:24:06 +0000 (10:24 +0000)]
Improve the comment in previous

llvm-svn: 349296

5 years agoExpand TSan sysroot workaround to NetBSD
Kamil Rytarowski [Sun, 16 Dec 2018 10:22:30 +0000 (10:22 +0000)]
Expand TSan sysroot workaround to NetBSD

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

llvm-svn: 349295

5 years ago[test] [ctime] Ignore -Wformat-zero-length warnings
Michal Gorny [Sun, 16 Dec 2018 09:18:31 +0000 (09:18 +0000)]
[test] [ctime] Ignore -Wformat-zero-length warnings

Explicitly disable the -Wformat-zero-length diagnostic when running
ctime tests, since one of the test cases passes zero-length format
string to strftime().  When strftime() is appropriately decorated
with __attribute__(format, ...), this caused the test to fail because
of this warning (e.g. on NetBSD).

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

llvm-svn: 349294

5 years ago[regex] Use distinct __regex_word on NetBSD
Michal Gorny [Sun, 16 Dec 2018 09:18:26 +0000 (09:18 +0000)]
[regex] Use distinct __regex_word on NetBSD

NetBSD defines character classes up to 0x2000.  Use 0x8000 as a safe
__regex_word that hopefully will not collide with other values
in the foreseeable future.

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

llvm-svn: 349293

5 years ago[gn build] Merge r349167
Nico Weber [Sun, 16 Dec 2018 02:32:20 +0000 (02:32 +0000)]
[gn build] Merge r349167

llvm-svn: 349291

5 years ago[gn build] Add build files for obj2yaml, yaml2obj, and lib/ObjectYAML
Nico Weber [Sun, 16 Dec 2018 02:29:02 +0000 (02:29 +0000)]
[gn build] Add build files for obj2yaml, yaml2obj, and lib/ObjectYAML

The two executables are needed by check-lld.

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

llvm-svn: 349290

5 years ago[gn build] Add build files for llvm-as, llvm-dis, llvm-dwarfdump, llvm-mc, FileCheck...
Nico Weber [Sun, 16 Dec 2018 02:27:10 +0000 (02:27 +0000)]
[gn build] Add build files for llvm-as, llvm-dis, llvm-dwarfdump, llvm-mc, FileCheck, count, not

These executables are needed by check-lld.

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

llvm-svn: 349289

5 years agoFix a lit test failure after MallocChecker changes
Kristof Umann [Sun, 16 Dec 2018 00:00:18 +0000 (00:00 +0000)]
Fix a lit test failure after MallocChecker changes

llvm-svn: 349288

5 years ago[X86] Autogenerate complete checks. NFC
Craig Topper [Sat, 15 Dec 2018 22:52:57 +0000 (22:52 +0000)]
[X86] Autogenerate complete checks. NFC

llvm-svn: 349287

5 years ago[X86] Begin cleaning up combineOr -> SHLD/SHRD. NFCI.
Simon Pilgrim [Sat, 15 Dec 2018 21:11:49 +0000 (21:11 +0000)]
[X86] Begin cleaning up combineOr -> SHLD/SHRD. NFCI.

In preparation for converting to funnel shifts.

llvm-svn: 349286

5 years ago[X86] Lower to SHLD/SHRD on slow machines for optsize
Simon Pilgrim [Sat, 15 Dec 2018 19:43:44 +0000 (19:43 +0000)]
[X86] Lower to SHLD/SHRD on slow machines for optsize

Use consistent rules for when to lower to SHLD/SHRD for slow machines - fixes a weird issue where funnel shift gets expanded but then X86ISelLowering's combineOr sees the optsize and combines to SHLD/SHRD, but now with the modulo amount guard......

llvm-svn: 349285

5 years ago[X86] Add optsize SHLD/SHRD tests
Simon Pilgrim [Sat, 15 Dec 2018 19:32:26 +0000 (19:32 +0000)]
[X86] Add optsize SHLD/SHRD tests

llvm-svn: 349284

5 years ago[analyzer][MallocChecker] Improve warning messages on double-delete errors
Kristof Umann [Sat, 15 Dec 2018 18:41:37 +0000 (18:41 +0000)]
[analyzer][MallocChecker] Improve warning messages on double-delete errors

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

llvm-svn: 349283

5 years agoUpdate the vFile:open: description to note that the flags
Jason Molenda [Sat, 15 Dec 2018 18:40:38 +0000 (18:40 +0000)]
Update the vFile:open: description to note that the flags
in the packet are lldb enum values, not the open(2) oflags --
forgot about that wrinkle.  Also added a comment to File.h
noting that the existing values cannot be modified or we'll
have a compatibilty break with any alternative platform
implementations, or older versions of lldb-server.

llvm-svn: 349282

5 years ago[analyzer][MallocChecker][NFC] Document and reorganize some functions
Kristof Umann [Sat, 15 Dec 2018 18:34:00 +0000 (18:34 +0000)]
[analyzer][MallocChecker][NFC] Document and reorganize some functions

This patch merely reorganizes some things, and features no functional change.

In detail:

* Provided documentation, or moved existing documentation in more obvious
places.
* Added dividers. (the //===----------===// thing).
* Moved getAllocationFamily, printAllocDeallocName, printExpectedAllocName and
printExpectedDeallocName in the global namespace on top of the file where
AllocationFamily is declared, as they are very strongly related.
* Moved isReleased and MallocUpdateRefState near RefState's definition for the
same reason.
* Realloc modeling was very poor in terms of variable and structure naming, as
well as documentation, so I renamed some of them and added much needed docs.
* Moved function IdentifierInfos to a separate struct, and moved isMemFunction,
isCMemFunction adn isStandardNewDelete inside it. This makes the patch affect
quite a lot of lines, should I extract it to a separate one?
* Moved MallocBugVisitor out of MallocChecker.
* Preferred switches to long else-if branches in some places.
* Neatly organized some RUN: lines.

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

llvm-svn: 349281

5 years ago[analyzer][NFC] Merge ClangCheckerRegistry to CheckerRegistry
Kristof Umann [Sat, 15 Dec 2018 18:11:49 +0000 (18:11 +0000)]
[analyzer][NFC] Merge ClangCheckerRegistry to CheckerRegistry

Now that CheckerRegistry lies in Frontend, we can finally eliminate
ClangCheckerRegistry. Fortunately, this also provides us with a
DiagnosticsEngine, so I went ahead and removed some parameters from it's
methods.

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

llvm-svn: 349280

5 years agoLink examples/clang-interpreter against clangSerialization
Kristof Umann [Sat, 15 Dec 2018 18:03:15 +0000 (18:03 +0000)]
Link examples/clang-interpreter against clangSerialization

llvm-svn: 349279

5 years agoFix a compilation error in examples/
Kristof Umann [Sat, 15 Dec 2018 17:12:38 +0000 (17:12 +0000)]
Fix a compilation error in examples/

llvm-svn: 349278

5 years agoAdd NetBSD support in needsRuntimeRegistrationOfSectionRange.
Kamil Rytarowski [Sat, 15 Dec 2018 16:51:35 +0000 (16:51 +0000)]
Add NetBSD support in needsRuntimeRegistrationOfSectionRange.

Use linker script magic to get data/cnts/name start/end.

llvm-svn: 349277

5 years agoRegister kASan shadow offset for NetBSD/amd64
Kamil Rytarowski [Sat, 15 Dec 2018 16:32:41 +0000 (16:32 +0000)]
Register kASan shadow offset for NetBSD/amd64

The NetBSD x86_64 kernel uses the 0xdfff900000000000 shadow
offset.

llvm-svn: 349276

5 years ago[analyzer][NFC] Move CheckerRegistry from the Core directory to Frontend
Kristof Umann [Sat, 15 Dec 2018 16:23:51 +0000 (16:23 +0000)]
[analyzer][NFC] Move CheckerRegistry from the Core directory to Frontend

ClangCheckerRegistry is a very non-obvious, poorly documented, weird concept.
It derives from CheckerRegistry, and is placed in lib/StaticAnalyzer/Frontend,
whereas it's base is located in lib/StaticAnalyzer/Core. It was, from what I can
imagine, used to circumvent the problem that the registry functions of the
checkers are located in the clangStaticAnalyzerCheckers library, but that
library depends on clangStaticAnalyzerCore. However, clangStaticAnalyzerFrontend
depends on both of those libraries.

One can make the observation however, that CheckerRegistry has no place in Core,
it isn't used there at all! The only place where it is used is Frontend, which
is where it ultimately belongs.

This move implies that since
include/clang/StaticAnalyzer/Checkers/ClangCheckers.h only contained a single function:

class CheckerRegistry;

void registerBuiltinCheckers(CheckerRegistry &registry);

it had to re purposed, as CheckerRegistry is no longer available to
clangStaticAnalyzerCheckers. It was renamed to BuiltinCheckerRegistration.h,
which actually describes it a lot better -- it does not contain the registration
functions for checkers, but only those generated by the tblgen files.

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

llvm-svn: 349275

5 years ago[analyzer] Prefer returns values to out-params in CheckerRegistry.cpp
Kristof Umann [Sat, 15 Dec 2018 15:44:05 +0000 (15:44 +0000)]
[analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

Renaming collectCheckers to getEnabledCheckers
Changing the functionality to acquire all enabled checkers, rather then collect
checkers for a specific CheckerOptInfo (for example, collecting all checkers for
{ "core", true }, which meant enabling all checkers from the core package, which
was an unnecessary complication).
Removing CheckerOptInfo, instead of storing whether the option was claimed via a
field, we handle errors immediately, as getEnabledCheckers can now access a
DiagnosticsEngine. Realize that the remaining information it stored is directly
accessible through AnalyzerOptions.CheckerControlList.
Fix a test with -analyzer-disable-checker -verify accidentally left in.

llvm-svn: 349274

5 years ago[CodeGen] Enhance machine PHIs optimization
Dinar Temirbulatov [Sat, 15 Dec 2018 14:37:01 +0000 (14:37 +0000)]
[CodeGen] Enhance machine PHIs optimization

Summary:
Make machine PHIs optimization to work for single value register taken from
several different copies. This is the first step to fix PR38917. This change
allows to get rid of redundant PHIs (see opt_phis2.mir test) to make
the subsequent optimizations (like CSE) possible and simpler.

For instance, before this patch the code like this:

%b = COPY %z
...
%a = PHI %bb1, %a; %bb2, %b
could be optimized to:

%a = %b
but the code like this:

%c = COPY %z
...
%b = COPY %z
...
%a = PHI %bb1, %a; %bb2, %b; %bb3, %c
would remain unchanged.
With this patch the latter case will be optimized:

%a = %z```.

Committed on behalf of: Anton Afanasyev anton.a.afanasyev@gmail.com

Reviewers: RKSimon, MatzeB

Subscribers: llvm-commits

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

llvm-svn: 349271

5 years agoRegenerate neon copy tests. NFCI.
Simon Pilgrim [Sat, 15 Dec 2018 14:23:18 +0000 (14:23 +0000)]
Regenerate neon copy tests. NFCI.

llvm-svn: 349270

5 years agolldb-test: Improve newline handling
Pavel Labath [Sat, 15 Dec 2018 13:49:25 +0000 (13:49 +0000)]
lldb-test: Improve newline handling

Summary:
Previously lldb-test's LinePrinter would output the indentation spaces
even on completely empty lines. This is not nice, as trailing spaces get
flagged as errors in some tools/editors, and it prevents FileCheck's
CHECK-EMPTY from working.

Equally annoying was the fact that the LinePrinter did not terminate
it's output with a newline (instead it would leave the unterminated hanging
indent from the last NewLine() command), which meant that the shell prompt
following the lldb-test command came out wrong.

This fixes both issues by changing how newlines are handled. NewLine(),
which was ending the previous line ('\n') *and* begging the next line by
printing the indent, is now "demoted" to just printing literal "\n".
Instead, lines are now delimited via a helper Line object, which makes
sure the line is indented and terminated in an RAII fashion. The typical
usage would be:
Printer.line() << "This text will be indented and terminated";
If one needs to do more work than it will fit into a single statement,
one can also assign the result of the line() function to a local
variable. The line will then be terminated when that object goes out of
scope.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 349269

5 years agoELF: more section creation cleanup
Pavel Labath [Sat, 15 Dec 2018 13:45:38 +0000 (13:45 +0000)]
ELF: more section creation cleanup

Summary:
This patch attempts to move as much code as possible out of the
CreateSections function to make room for future improvements there. Some
of this may be slightly over-engineered (VMAddressProvider), but I
wanted to keep the logic of this function very simple, because once I
start taking segment headers into acount (as discussed in D55356), the
function is going to grow significantly.

While in there, I also added tests for various bits of functionality.

This should be NFC, except that I changed the order of hac^H^Heuristicks
for determining section type slightly. Previously, name-based deduction
(.symtab -> symtab) would take precedence over type-based (SHT_SYMTAB ->
symtab) one. In fact we would assert if we ran into a .text section with
type SHT_SYMTAB. Though unlikely to matter in practice, this order
seemed wrong to me, so I have inverted it.

Reviewers: clayborg, krytarowski, espindola

Subscribers: emaste, arichardson, lldb-commits

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

llvm-svn: 349268

5 years agoRemove /proc/pid/maps parsing code from NativeProcessLinux
Pavel Labath [Sat, 15 Dec 2018 13:38:16 +0000 (13:38 +0000)]
Remove /proc/pid/maps parsing code from NativeProcessLinux

A utility function doing this was added in r349182, so use that instead.

llvm-svn: 349267

5 years ago[analyzer] Assume that we always have a SubEngine available
Gabor Horvath [Sat, 15 Dec 2018 13:20:33 +0000 (13:20 +0000)]
[analyzer] Assume that we always have a SubEngine available

The removed codepath was dead.

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

llvm-svn: 349266

5 years agoFix -Wunused-variable warning. NFCI.
Simon Pilgrim [Sat, 15 Dec 2018 12:25:22 +0000 (12:25 +0000)]
Fix -Wunused-variable warning. NFCI.

llvm-svn: 349265

5 years ago[TargetLowering] Add ISD::OR + ISD::XOR handling to SimplifyDemandedVectorElts
Simon Pilgrim [Sat, 15 Dec 2018 11:36:36 +0000 (11:36 +0000)]
[TargetLowering] Add ISD::OR + ISD::XOR handling to SimplifyDemandedVectorElts

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

llvm-svn: 349264

5 years agoEnable test/msan/pthread_getname_np.cc for NetBSD
Kamil Rytarowski [Sat, 15 Dec 2018 10:42:14 +0000 (10:42 +0000)]
Enable test/msan/pthread_getname_np.cc for NetBSD

llvm-svn: 349263

5 years agoEnable SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP for NetBSD
Kamil Rytarowski [Sat, 15 Dec 2018 10:41:55 +0000 (10:41 +0000)]
Enable SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP for NetBSD

llvm-svn: 349262

5 years ago[InstSimplify] Add tests for saturating add/sub + icmp; NFC
Nikita Popov [Sat, 15 Dec 2018 10:37:01 +0000 (10:37 +0000)]
[InstSimplify] Add tests for saturating add/sub + icmp; NFC

If a saturating add/sub with a constant operand is compared to
another constant, we should be able to determine that the condition
is always true/false in some cases (but currently don't).

llvm-svn: 349261

5 years ago[OpenMP] Fixes for LIBOMP_OMP_VERSION=45/40
Roman Lebedev [Sat, 15 Dec 2018 09:23:39 +0000 (09:23 +0000)]
[OpenMP] Fixes for LIBOMP_OMP_VERSION=45/40

Summary:
I have discovered this because i wanted to experiment with
building static libomp (with openmp-4.0 support only)
for debugging purposes.

There are three kinds of problems here:
1. `__kmp_compare_and_store_acq()` simply does not exist.
   It was added in D47903 by @jlpeyton.
   I'm guessing `__kmp_atomic_compare_store_acq()` was meant.
2. In `__kmp_is_ticket_lock_initialized()`,
   `lck->lk.initialized` is `std::atomic<bool>`,
   while `lck` is `kmp_ticket_lock_t *`.
   Naturally, they can't be equality-compared.
   Either, it should return the value read from `lck->lk.initialized`,
   or do what `__kmp_is_queuing_lock_initialized()` does,
   compare the passed pointer with the field in the struct
   pointed by the pointer. I think the latter is correct-er choice here.
3. Tests were not versioned.
   They assume that `LIBOMP_OMP_VERSION` is at the latest version.

This does not touch LIBOMP_OMP_VERSION=30. That is still broken.

Reviewers: jlpeyton, Hahnfeld, AndreyChurbanov

Reviewed By: AndreyChurbanov

Subscribers: guansong, jfb, openmp-commits, jlpeyton

Tags: #openmp

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

llvm-svn: 349260

5 years ago[libclang] Add dependency on clangSerialization to unbreak -DBUILD_SHARED_LIBS=1...
Fangrui Song [Sat, 15 Dec 2018 08:54:06 +0000 (08:54 +0000)]
[libclang] Add dependency on clangSerialization to unbreak -DBUILD_SHARED_LIBS=1 build after rC349237

Frontend headers have undefined reference on the symbol `clang::PCHContainerOperations::PCHContainerOperations()` through some shared_ptr usage. Any dependents will get the undefined reference which can only be resolved by explicit dependency on clangSerialization (due to -z defs).

llvm-svn: 349259

5 years ago[mips] Fix test typo in rL348914
Fangrui Song [Sat, 15 Dec 2018 08:44:47 +0000 (08:44 +0000)]
[mips] Fix test typo in rL348914

RUN; -> RUN:

llvm-svn: 349258

5 years agoFix internal_sleep() for NetBSD
Kamil Rytarowski [Sat, 15 Dec 2018 08:25:25 +0000 (08:25 +0000)]
Fix internal_sleep() for NetBSD

This is a follow up of a similar fix for Linux from D55692.

llvm-svn: 349257

5 years ago[MinGW] Produce a vtable and RTTI for dllexported classes without a key function
Martin Storsjo [Sat, 15 Dec 2018 08:08:11 +0000 (08:08 +0000)]
[MinGW] Produce a vtable and RTTI for dllexported classes without a key function

This matches what GCC does in these situations.

This fixes compiling Qt in debug mode. In release mode, references to
the vtable of this particular class ends up optimized away, but in debug
mode, the compiler creates references to the vtable, which is expected
to be dllexported from a different DLL. Make sure the dllexported
version actually ends up emitted.

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

llvm-svn: 349256

5 years agoFix typo in test cases as well.
Peter Collingbourne [Sat, 15 Dec 2018 07:08:04 +0000 (07:08 +0000)]
Fix typo in test cases as well.

llvm-svn: 349255

5 years agohwasan: Fix typo: Previosly -> Previously.
Peter Collingbourne [Sat, 15 Dec 2018 07:06:24 +0000 (07:06 +0000)]
hwasan: Fix typo: Previosly -> Previously.

llvm-svn: 349254

5 years agoFix static assert diagnostic checks in i386
Eric Fiselier [Sat, 15 Dec 2018 05:18:56 +0000 (05:18 +0000)]
Fix static assert diagnostic checks in i386

llvm-svn: 349252

5 years ago[Power9][NFC] add setb exploitation test case
Kewen Lin [Sat, 15 Dec 2018 04:39:37 +0000 (04:39 +0000)]
[Power9][NFC] add setb exploitation test case

Add an original test case for setb before the exploitation actually takes effect, later we can check the difference.

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

llvm-svn: 349251

5 years agoFix includes and dependencies for libclang
Richard Trieu [Sat, 15 Dec 2018 04:25:19 +0000 (04:25 +0000)]
Fix includes and dependencies for libclang

Remove unneeded includes
Add needed include
Remove dependency on Serialization

llvm-svn: 349237

5 years agoTry 2: Fix bug in buildbot start script
Eric Fiselier [Sat, 15 Dec 2018 03:48:08 +0000 (03:48 +0000)]
Try 2: Fix bug in buildbot start script

llvm-svn: 349236

5 years agoFix bug in buildbot start script
Eric Fiselier [Sat, 15 Dec 2018 03:45:21 +0000 (03:45 +0000)]
Fix bug in buildbot start script

llvm-svn: 349235

5 years agoRework docker setup to make it easier to work around bugs on buildbots
Eric Fiselier [Sat, 15 Dec 2018 03:24:33 +0000 (03:24 +0000)]
Rework docker setup to make it easier to work around bugs on buildbots

llvm-svn: 349234

5 years agoRevert "[analyzer] MoveChecker: Add checks for dereferencing a smart pointer..."
Artem Dergachev [Sat, 15 Dec 2018 02:55:55 +0000 (02:55 +0000)]
Revert "[analyzer] MoveChecker: Add checks for dereferencing a smart pointer..."

This reverts commit r349226.

Fails on an MSVC buildbot.

llvm-svn: 349233

5 years agoAh, forgot qModuleInfo. Need to look that one up
Jason Molenda [Sat, 15 Dec 2018 02:51:01 +0000 (02:51 +0000)]
Ah, forgot qModuleInfo.  Need to look that one up
and finish filling this in.

llvm-svn: 349232

5 years agoA brief outline of the packets that need to be implemented
Jason Molenda [Sat, 15 Dec 2018 02:36:39 +0000 (02:36 +0000)]
A brief outline of the packets that need to be implemented
to write an lldb platform server that doesn't link against
LLDB.framework to be able to fully run the lldb testsuite
on a remote system.  The platform packets weren't covered
in the existing lldb-gdb-remote.txt doc, so I wanted to
jot them down in one place.

llvm-svn: 349231

5 years agoMove static analyzer core diagnostics to common.
Richard Trieu [Sat, 15 Dec 2018 02:30:16 +0000 (02:30 +0000)]
Move static analyzer core diagnostics to common.

llvm-svn: 349230

5 years ago[analyzer] Fix unknown block calls to have zero parameters.
Artem Dergachev [Sat, 15 Dec 2018 02:13:26 +0000 (02:13 +0000)]
[analyzer] Fix unknown block calls to have zero parameters.

Right now they report to have one parameter with null decl,
because initializing an ArrayRef of pointers with a nullptr
yields an ArrayRef to an array of one null pointer.

Fixes a crash in the OSObject section of RetainCountChecker.

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

llvm-svn: 349229

5 years ago[analyzer] ObjCDealloc: Fix a crash when a class attempts to deallocate a class.
Artem Dergachev [Sat, 15 Dec 2018 02:09:02 +0000 (02:09 +0000)]
[analyzer] ObjCDealloc: Fix a crash when a class attempts to deallocate a class.

The checker wasn't prepared to see the dealloc message sent to the class itself
rather than to an instance, as if it was +dealloc.

Additionally, it wasn't prepared for pure-unknown or undefined self values.
The new guard covers that as well, but it is annoying to test because
both kinds of values shouldn't really appear and we generally want to
get rid of all of them (by modeling unknown values with symbols and
by warning on use of undefined values before they are used).

The CHECK: directive for FileCheck at the end of the test looks useless,
so i removed it.

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

llvm-svn: 349228

5 years ago[analyzer] ObjCContainers: Track index values.
Artem Dergachev [Sat, 15 Dec 2018 02:06:13 +0000 (02:06 +0000)]
[analyzer] ObjCContainers: Track index values.

Use trackExpressionValue() (previously known as trackNullOrUndefValue())
to track index value in the report, so that the user knew
what Static Analyzer thinks the index is.

Additionally, implement printState() to help debugging the checker later.

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

llvm-svn: 349227

5 years ago[analyzer] MoveChecker: Add checks for dereferencing a smart pointer after move.
Artem Dergachev [Sat, 15 Dec 2018 01:53:38 +0000 (01:53 +0000)]
[analyzer] MoveChecker: Add checks for dereferencing a smart pointer after move.

Calling operator*() or operator->() on a null STL smart pointer is
undefined behavior.

Smart pointers are specified to become null after being moved from.
So we can't warn on arbitrary method calls, but these two operators
definitely make no sense.

The new bug is fatal because it's an immediate UB,
unlike other use-after-move bugs.

The work on a more generic null smart pointer dereference checker
is still pending.

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

llvm-svn: 349226

5 years ago[analyzer] MoveChecker: NFC: De-duplicate a few checks.
Artem Dergachev [Sat, 15 Dec 2018 01:50:58 +0000 (01:50 +0000)]
[analyzer] MoveChecker: NFC: De-duplicate a few checks.

No functional change intended.

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

llvm-svn: 349225

5 years ago[SILoadStoreOptimizer] Use std::abs to avoid truncation.
Florian Hahn [Sat, 15 Dec 2018 01:32:58 +0000 (01:32 +0000)]
[SILoadStoreOptimizer] Use std::abs to avoid truncation.

Using regular abs() causes the following warning

error: absolute value function 'abs' given an argument of type 'int64_t' (aka 'long') but has parameter of type 'int' which may cause truncation of value [-Werror,-Wabsolute-value]
        (uint32_t)abs(Dist) > MaxDist) {
                  ^
lib/Target/AMDGPU/SILoadStoreOptimizer.cpp:1369:19: note: use function 'std::abs' instead

which causes a bot to fail:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/18284/steps/bootstrap%20clang/logs/stdio

llvm-svn: 349224

5 years ago[X86] Rename hasNoSignedComparisonUses to hasNoSignFlagUses. Add the instruction...
Craig Topper [Sat, 15 Dec 2018 01:07:19 +0000 (01:07 +0000)]
[X86] Rename hasNoSignedComparisonUses to hasNoSignFlagUses. Add the instruction that only modify the O flag to the waiver list.

The only caller of this turns CMP with 0 into TEST. CMP with 0 and TEST both set OF to 0 so we should have no issues with instructions that only use OF.

Though I don't think there's any reason we would read just OF after a compare with 0 anyway. So this probably isn't an observable change.

llvm-svn: 349223

5 years ago[X86] Make hasNoCarryFlagUses/hasNoSignedComparisonUses take an SDValue that indicate...
Craig Topper [Sat, 15 Dec 2018 01:07:16 +0000 (01:07 +0000)]
[X86] Make hasNoCarryFlagUses/hasNoSignedComparisonUses take an SDValue that indicates which result is the flag result. NFCI

hasNoCarryFlagUses hardcoded that the flag result is 1 and used that to filter which uses were of interest. hasNoSignedComparisonUses just assumes the only result is flags and checks whether any user of the node is a CopyToReg instruction.

After this patch we now do a result number check in both and rely on the caller to provide the result number.

This shouldn't change behavior it was just an odd difference between the two functions that I noticed.

llvm-svn: 349222

5 years ago[WebAssembly] Check if the section order is correct
Heejin Ahn [Sat, 15 Dec 2018 00:58:12 +0000 (00:58 +0000)]
[WebAssembly] Check if the section order is correct

Summary:
This patch checks if the section order is correct when reading a wasm
object file in `WasmObjectFile` and converting YAML to wasm object in
yaml2wasm. (It is not possible to check when reading YAML because it is
handled exclusively by the YAML reader.)

This checks the ordering of all known sections (core sections + known
custom sections). This also adds section ID DataCount section that will
be scheduled to be added in near future.

Reviewers: sbc100

Subscribers: dschuff, mgorny, jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 349221

5 years ago[NewGVN] Update use counts for SSA copies when replacing them by their operands.
Florian Hahn [Sat, 15 Dec 2018 00:32:38 +0000 (00:32 +0000)]
[NewGVN] Update use counts for SSA copies when replacing them by their operands.

The current code relies on LeaderUseCount to determine if we can remove
an SSA copy, but in that the LeaderUseCount does not refer to the SSA
copy. If a SSA copy is a dominating leader, we use the operand as dominating
leader instead. This means we removed a user of a ssa copy and we should
decrement its use count, so we can remove the ssa copy once it becomes dead.

Fixes PR38804.

Reviewers: efriedma, davide

Reviewed By: davide

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

llvm-svn: 349217

5 years agoELF: Handle R_ARM_V4BX correctly in PIC output files.
Peter Collingbourne [Sat, 15 Dec 2018 00:20:17 +0000 (00:20 +0000)]
ELF: Handle R_ARM_V4BX correctly in PIC output files.

Previously we considered R_ARM_V4BX to be an absolute relocation,
which meant that we rejected it in read-only sections in PIC output
files. Instead, treat it as a hint relocation so that relocation
processing ignores it entirely.

Also fix a problem with the test case where it was never being run
because it has a .yaml extension and we don't run tests with that
extension.

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

llvm-svn: 349216

5 years agoSimplify Boolean expressions
Jonas Devlieghere [Sat, 15 Dec 2018 00:15:33 +0000 (00:15 +0000)]
Simplify Boolean expressions

This patch simplifies boolean expressions acorss LLDB. It was generated
using clang-tidy with the following command:

run-clang-tidy.py -checks='-*,readability-simplify-boolean-expr' -format -fix $PWD

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

llvm-svn: 349215

5 years ago[Util] Refer to [s|z]exts of args when converting dbg.declares (fix PR35400)
Vedant Kumar [Sat, 15 Dec 2018 00:03:33 +0000 (00:03 +0000)]
[Util] Refer to [s|z]exts of args when converting dbg.declares (fix PR35400)

When converting dbg.declares, if the described value is a [s|z]ext,
refer to the ext directly instead of referring to its operand.

This fixes a narrowing bug (the debugger got the sign of a variable
wrong, see llvm.org/PR35400).

The main reason to refer to the ext's operand was that an optimization
may remove the ext itself, leading to a dropped variable. Now that
InstCombine has been taught to use replaceAllDbgUsesWith (r336451), this
is less of a concern. Other passes can/should adopt this API as needed
to fix dropped variable bugs.

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

llvm-svn: 349214

5 years ago[NVPTX] Lower instructions that expand into libcalls.
Artem Belevich [Fri, 14 Dec 2018 23:53:06 +0000 (23:53 +0000)]
[NVPTX] Lower instructions that expand into libcalls.

The change is an effort to split and refactor abandoned
D34708 into smaller parts.

Here the behaviour of unsupported instructions is changed
to match the behaviour of explicit intrinsics calls.
Currently LLVM crashes with:
> Assertion getInstruction() && "Not a call or invoke instruction!" failed.

With this patch LLVM produces a more sensible error message:
> Cannot select: ... i32 = ExternalSymbol'__foobar'

Author: Denys Zariaiev <denys.zariaiev@gmail.com>

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

llvm-svn: 349213

5 years agoMangle calling conventions into function pointer types where GCC does
Reid Kleckner [Fri, 14 Dec 2018 23:42:59 +0000 (23:42 +0000)]
Mangle calling conventions into function pointer types where GCC does

Summary:
GCC 5.1 began mangling these Windows calling conventions into function
types, since they can be used for overloading. They've always been
mangled in the MS ABI, but they are new to the Itanium mangler. Note
that the calling convention doesn't appear as part of the main
declaration, it only appears on function parameter types and other
types.

Fixes PR39860

Reviewers: rjmccall, efriedma

Subscribers: cfe-commits

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

llvm-svn: 349212

5 years agoFix the unittests for the move of Listener & Broadcaster
Jim Ingham [Fri, 14 Dec 2018 23:27:08 +0000 (23:27 +0000)]
Fix the unittests for the move of Listener & Broadcaster
from Core to Utility.

llvm-svn: 349211

5 years ago[libFuzzer] make len_control less aggressive
Kostya Serebryany [Fri, 14 Dec 2018 23:21:31 +0000 (23:21 +0000)]
[libFuzzer] make len_control less aggressive

llvm-svn: 349210

5 years agoAdd AddressSpace mangling to MS mode
Erich Keane [Fri, 14 Dec 2018 23:17:34 +0000 (23:17 +0000)]
Add AddressSpace mangling to MS mode

All of the symbols demangle on llvm-undname and demangler.com. This
address space qualifier is useful for when we want to use opencl C++ in
Windows mode. Additionally, C++ address-space using functions will now
be usable on windows.

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

Change-Id: Ife4506613c3cce778a783456d62117fbf7d83c26
llvm-svn: 349209

5 years agoUpdate a comment according to r255360 "Remove -r and -R options from dotest.py"
Tatyana Krasnukha [Fri, 14 Dec 2018 23:02:41 +0000 (23:02 +0000)]
Update a comment according to r255360 "Remove -r and -R options from dotest.py"

llvm-svn: 349208

5 years agoDebugInfo: Avoid using split DWARF when the split unit would be empty.
David Blaikie [Fri, 14 Dec 2018 22:44:46 +0000 (22:44 +0000)]
DebugInfo: Avoid using split DWARF when the split unit would be empty.

In ThinLTO many split CUs may be effectively empty because of the lack
of support for cross-unit references in split DWARF.

Using a split unit in those cases is just a waste/overhead - and turned
out to be one contributor to a significant symbolizer performance issue
when global variable debug info was being imported (see r348416 for the
primary fix) due to symbolizers seeing CUs with no ranges, assuming
there might still be addresses covered and walking into the split CU to
see if there are any ranges (when that split CU was in a DWP file, that
meant loading the DWP and its index, the index was extra large because
of all these fractured/empty CUs... and so was very expensive to load).

(the 3rd fix which will follow, is to assume that a CU with no ranges is
empty rather than merely missing its CU level range data - and to not
walk into its DIEs (split or otherwise) in search of address information
that is generally not present)

llvm-svn: 349207

5 years agoRevert "Add extension to always default-initialize nullptr_t."
Erich Keane [Fri, 14 Dec 2018 22:41:18 +0000 (22:41 +0000)]
Revert "Add extension to always default-initialize nullptr_t."

This reverts commit 46efdf2ccc2a80aefebf8433dbf9c7c959f6e629.

Richard Smith commented just after I submitted this that this is the
wrong solution.  Reverting so that I can fix differently.

llvm-svn: 349206

5 years ago[codeview] Add begin/endSymbolRecord helpers, NFC
Reid Kleckner [Fri, 14 Dec 2018 22:40:28 +0000 (22:40 +0000)]
[codeview] Add begin/endSymbolRecord helpers, NFC

Previously beginning a symbol record was excessively verbose. Now it's a
bit simpler. This follows the same pattern as begin/endCVSubsection.

llvm-svn: 349205