lldb.git
2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 years ago[test] Capture stderr from 'tar --version' call as well
Michal Gorny [Fri, 14 Dec 2018 22:38:01 +0000 (22:38 +0000)]
[test] Capture stderr from 'tar --version' call as well

Capture the stderr from 'tar --version' call as otherwise error messages
spill onto user's terminal unnecessarily (e.g. on NetBSD where tar does
not support long options).  While at it, refactor the code to use
communicate() instead of reinventing the wheel.

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

llvm-svn: 349204

2 years agoDebugInfo: Move addAddrBase from DwarfUnit to DwarfCompileUnit
David Blaikie [Fri, 14 Dec 2018 22:34:03 +0000 (22:34 +0000)]
DebugInfo: Move addAddrBase from DwarfUnit to DwarfCompileUnit

Only CUs need an address table reference.

llvm-svn: 349203

2 years ago[Hexagon] Add patterns for shifts of v2i16
Krzysztof Parzyszek [Fri, 14 Dec 2018 22:33:48 +0000 (22:33 +0000)]
[Hexagon] Add patterns for shifts of v2i16

This fixes https://llvm.org/PR39983.

llvm-svn: 349202

2 years agoAdd extension to always default-initialize nullptr_t.
Erich Keane [Fri, 14 Dec 2018 22:22:29 +0000 (22:22 +0000)]
Add extension to always default-initialize nullptr_t.

Core issue 1013 suggests that having an uninitialied std::nullptr_t be
UB is a bit foolish, since there is only a single valid value. This DR
reports that DR616 fixes it, which does so by making lvalue-to-rvalue
conversions from nullptr_t be equal to nullptr.

However, just implementing that results in warnings/etc in many places.
In order to fix all situations where nullptr_t would seem uninitialized,
this patch instead (as an otherwise transparent extension) default
initializes uninitialized VarDecls of nullptr_t.

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

Change-Id: I84d72a9290054fa55341e8cbdac43c8e7f25b885
llvm-svn: 349201

2 years ago[GlobalISel] LegalizerHelper: Implement fewerElementsVector for G_LOAD/G_STORE
Volkan Keles [Fri, 14 Dec 2018 22:11:20 +0000 (22:11 +0000)]
[GlobalISel] LegalizerHelper: Implement fewerElementsVector for G_LOAD/G_STORE

Reviewers: aemerson, dsanders, bogner, paquette, aditya_nandakumar

Reviewed By: dsanders

Subscribers: rovka, kristof.beyls, javed.absar, tschuett, llvm-commits

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

llvm-svn: 349200

2 years ago[Hexagon] Use IMPLICIT_DEF to any-extend 32-bit values to 64 bits
Krzysztof Parzyszek [Fri, 14 Dec 2018 22:05:44 +0000 (22:05 +0000)]
[Hexagon] Use IMPLICIT_DEF to any-extend 32-bit values to 64 bits

llvm-svn: 349199

2 years agoAdd --plugin-opt=emit-llvm option.
Rui Ueyama [Fri, 14 Dec 2018 21:58:49 +0000 (21:58 +0000)]
Add --plugin-opt=emit-llvm option.

`--plugin-opt=emit-llvm` is an option for LTO. It makes the linker to
combine all bitcode files and write the result to an output file without
doing codegen. Gold LTO plugin has this option.

This option is being used for some post-link code analysis tools that
have to see a whole program but don't need to see them in the native
machine code.

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

llvm-svn: 349198

2 years agoUsing llvm::find_if() instead of a range-based for loop; NFC.
Aaron Ballman [Fri, 14 Dec 2018 21:14:44 +0000 (21:14 +0000)]
Using llvm::find_if() instead of a range-based for loop; NFC.

This addresses post-commit review feedback from r349188.

llvm-svn: 349197

2 years ago[AMDGPU] Promote constant offset to the immediate by finding a new base with 13bit...
Farhana Aleen [Fri, 14 Dec 2018 21:13:14 +0000 (21:13 +0000)]
[AMDGPU] Promote constant offset to the immediate by finding a new base with 13bit constant offset from the nearby instructions.

Summary: Promote constant offset to immediate by recomputing the relative 13bit offset from nearby instructions.
 E.g.
  s_movk_i32 s0, 0x1800
  v_add_co_u32_e32 v0, vcc, s0, v2
  v_addc_co_u32_e32 v1, vcc, 0, v6, vcc

  s_movk_i32 s0, 0x1000
  v_add_co_u32_e32 v5, vcc, s0, v2
  v_addc_co_u32_e32 v6, vcc, 0, v6, vcc
  global_load_dwordx2 v[5:6], v[5:6], off
  global_load_dwordx2 v[0:1], v[0:1], off
  =>
  s_movk_i32 s0, 0x1000
  v_add_co_u32_e32 v5, vcc, s0, v2
  v_addc_co_u32_e32 v6, vcc, 0, v6, vcc
  global_load_dwordx2 v[5:6], v[5:6], off
  global_load_dwordx2 v[0:1], v[5:6], off offset:2048

Author: FarhanaAleen

Reviewed By: arsenm, rampitec

Subscribers: llvm-commits, AMDGPU

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

llvm-svn: 349196

2 years ago[Clang] Add __builtin_launder
Eric Fiselier [Fri, 14 Dec 2018 21:11:28 +0000 (21:11 +0000)]
[Clang] Add __builtin_launder

Summary:
This patch adds `__builtin_launder`, which is required to implement `std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings Clang in-line with GCC.

I'm not exactly sure what magic `__builtin_launder` requires, but  based on previous discussions this patch applies a `@llvm.invariant.group.barrier`. As noted in previous discussions, this may not be enough to correctly handle vtables.

Reviewers: rnk, majnemer, rsmith

Reviewed By: rsmith

Subscribers: kristina, Romain-Geissler-1A, erichkeane, amharc, jroelofs, cfe-commits, Prazek

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

llvm-svn: 349195

2 years agoRemove the Disassembly benchmarks.
Adrian Prantl [Fri, 14 Dec 2018 21:06:00 +0000 (21:06 +0000)]
Remove the Disassembly benchmarks.

While I was out hunting for remaining pexpect-based tests, I came
across these tests that can't possibly work an any modern system, as
they rely on having gdb available in /Developer.

This patch simply removes the test without replacement.

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

llvm-svn: 349194

2 years agoAdd missing includes and forward decls to unbreak build
Eric Fiselier [Fri, 14 Dec 2018 21:04:00 +0000 (21:04 +0000)]
Add missing includes and forward decls to unbreak build

llvm-svn: 349193

2 years ago[OPENMP][NVPTX]Improved interwarp copy function.
Alexey Bataev [Fri, 14 Dec 2018 21:00:58 +0000 (21:00 +0000)]
[OPENMP][NVPTX]Improved interwarp copy function.

Inlined runtime with the current implementation of the interwarp copy
function leads to the undefined behavior because of the not quite
correct implementation of the barriers. Start using generic
__kmpc_barier function instead of the custom made barriers.

llvm-svn: 349192

2 years ago[analyzer] MoveChecker Pt.6: Suppress the warning for the move-safe STL classes.
Artem Dergachev [Fri, 14 Dec 2018 20:52:57 +0000 (20:52 +0000)]
[analyzer] MoveChecker Pt.6: Suppress the warning for the move-safe STL classes.

Some C++ standard library classes provide additional guarantees about their
state after move. Suppress warnings on such classes until a more precise
behavior is implemented. Warnings for locals are not suppressed anyway
because it's still most likely a bug.

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

llvm-svn: 349191

2 years ago[analyzer] MoveChecker: Improve invalidation policies.
Artem Dergachev [Fri, 14 Dec 2018 20:47:58 +0000 (20:47 +0000)]
[analyzer] MoveChecker: Improve invalidation policies.

If a moved-from object is passed into a conservatively evaluated function
by pointer or by reference, we assume that the function may reset its state.

Make sure it doesn't apply to const pointers and const references. Add a test
that demonstrates that it does apply to rvalue references.

Additionally, make sure that the object is invalidated when its contents change
for reasons other than invalidation caused by evaluating a call conservatively.
In particular, when the object's fields are manipulated directly, we should
assume that some sort of reset may be happening.

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

llvm-svn: 349190

2 years agoTolerate Clangs new static_assert messages
Eric Fiselier [Fri, 14 Dec 2018 20:42:36 +0000 (20:42 +0000)]
Tolerate Clangs new static_assert messages

llvm-svn: 349189

2 years agoUpdate our SARIF support from 10-10 to 11-28.
Aaron Ballman [Fri, 14 Dec 2018 20:34:23 +0000 (20:34 +0000)]
Update our SARIF support from 10-10 to 11-28.

Functional changes include:

* The run.files property is now an array instead of a mapping.
* fileLocation objects now have a fileIndex property specifying the array index into run.files.
* The resource.rules property is now an array instead of a mapping.
* The result object was given a ruleIndex property that is an index into the resource.rules array.
* rule objects now have their "id" field filled out in addition to the name field.
* Updated the schema and spec version numbers to 11-28.

llvm-svn: 349188

2 years ago[libcxx] Mark some tests as still failing on macosx10.14
Louis Dionne [Fri, 14 Dec 2018 20:22:44 +0000 (20:22 +0000)]
[libcxx] Mark some tests as still failing on macosx10.14

llvm-svn: 349187

2 years ago[SDAG] Ignore chain operand in REG_SEQUENCE when emitting instructions
Krzysztof Parzyszek [Fri, 14 Dec 2018 20:14:12 +0000 (20:14 +0000)]
[SDAG] Ignore chain operand in REG_SEQUENCE when emitting instructions

llvm-svn: 349186

2 years ago[AArch64] Simplify the scheduling predicates (NFC)
Evandro Menezes [Fri, 14 Dec 2018 20:04:58 +0000 (20:04 +0000)]
[AArch64] Simplify the scheduling predicates (NFC)

The instruction encodings make it unnecessary to distinguish extended W-form
from X-form instructions.

llvm-svn: 349185

2 years ago[TransformWarning] Do not warn missed transformations in optnone functions.
Michael Kruse [Fri, 14 Dec 2018 19:45:43 +0000 (19:45 +0000)]
[TransformWarning] Do not warn missed transformations in optnone functions.

Optimization transformations are intentionally disabled by the 'optnone'
function attribute. Therefore do not warn if transformation metadata is
still present.

Using the legacy pass manager structure, the `skipFunction` method takes
care for the optnone attribute (already called before this patch). For
the new pass manager, there is no equivalent, so we check for the
'optnone' attribute manually.

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

llvm-svn: 349184

2 years agoAdd missing .dmp files to test inputs.
Greg Clayton [Fri, 14 Dec 2018 19:38:08 +0000 (19:38 +0000)]
Add missing .dmp files to test inputs.

llvm-svn: 349183

2 years agoCache memory regions in ProcessMinidump and use the linux maps as the source of the...
Greg Clayton [Fri, 14 Dec 2018 19:36:01 +0000 (19:36 +0000)]
Cache memory regions in ProcessMinidump and use the linux maps as the source of the information if available

Breakpad creates minidump files that sometimes have:
- linux maps textual content
- no MemoryInfoList

Right now unless the file has a MemoryInfoList we get no region information.

This patch:

- reads and caches the memory region info one time and sorts it for easy subsequent access
- get the region info from the best source in this order:
  - linux maps info (if available)
  - MemoryInfoList (if available)
  - MemoryList or Memory64List
- returns memory region info for the gaps between regions (before the first and after the last)

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

llvm-svn: 349182

2 years agoWhen resolving a merge conflict, I put something inside an #ifdef. Fixed.
Marshall Clow [Fri, 14 Dec 2018 19:25:22 +0000 (19:25 +0000)]
When resolving a merge conflict, I put something inside an #ifdef. Fixed.

llvm-svn: 349181

2 years agoFix Xcode project for MIPS architecture plug-in and move of Event, Listener and Broad...
Greg Clayton [Fri, 14 Dec 2018 19:22:24 +0000 (19:22 +0000)]
Fix Xcode project for MIPS architecture plug-in and move of Event, Listener and Broadcaster to Utility.

llvm-svn: 349180

2 years ago[x86] add tests for extractelement of FP binops; NFC
Sanjay Patel [Fri, 14 Dec 2018 19:15:54 +0000 (19:15 +0000)]
[x86] add tests for extractelement of FP binops; NFC

llvm-svn: 349179

2 years agoImplement P1209 - Adopt Consistent Container Erasure from Library Fundamentals 2...
Marshall Clow [Fri, 14 Dec 2018 18:49:35 +0000 (18:49 +0000)]
Implement P1209 - Adopt Consistent Container Erasure from Library Fundamentals 2 for C++20. Reviewed as https://reviews.llvm.org/D55532

llvm-svn: 349178

2 years ago[ARM] make test immune to scalarization improvements; NFC
Sanjay Patel [Fri, 14 Dec 2018 18:47:04 +0000 (18:47 +0000)]
[ARM] make test immune to scalarization improvements; NFC

llvm-svn: 349177

2 years ago[x86] make tests immune to scalarization improvements; NFC
Sanjay Patel [Fri, 14 Dec 2018 18:44:16 +0000 (18:44 +0000)]
[x86] make tests immune to scalarization improvements; NFC

llvm-svn: 349176

2 years ago[NativePDB] Fix local-variables.cpp test.
Zachary Turner [Fri, 14 Dec 2018 18:43:42 +0000 (18:43 +0000)]
[NativePDB] Fix local-variables.cpp test.

Since we're actually running an executable on the host now, different
versions of Windows could load different system libraries, so we need
to regex out the number of loaded modules.

llvm-svn: 349175

2 years ago[globalisel][combiner] Fix r349167 for release mode bots
Daniel Sanders [Fri, 14 Dec 2018 18:25:05 +0000 (18:25 +0000)]
[globalisel][combiner] Fix r349167 for release mode bots

This test relies on -debug-only which is unavailable in non-asserts builds.

llvm-svn: 349174

2 years ago[ADT] Fix bugs in SmallBitVector.
Zachary Turner [Fri, 14 Dec 2018 18:21:20 +0000 (18:21 +0000)]
[ADT] Fix bugs in SmallBitVector.

Fixes:
  * find_last/find_last_unset - off-by-one error
  * Compound assignment ops and operator== when mixing big/small modes

Patch by Brad Moody
Differential Revision: https://reviews.llvm.org/D54933

llvm-svn: 349173

2 years agoFix Visual Studio PointerIntPair visualizer
Zachary Turner [Fri, 14 Dec 2018 18:20:21 +0000 (18:20 +0000)]
Fix Visual Studio PointerIntPair visualizer

Patch by: Trass3r

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

llvm-svn: 349172

2 years ago[libcxx] Make sure use_system_cxx_lib does not override cxx_runtime_root for DYLD_LIB...
Louis Dionne [Fri, 14 Dec 2018 18:19:14 +0000 (18:19 +0000)]
[libcxx] Make sure use_system_cxx_lib does not override cxx_runtime_root for DYLD_LIBRARY_PATH

Otherwise, even specifying a runtime root different from the library
we're linking against won't work -- the library we're linking against
is always used. This is undesirable if we try testing something like
linking against a recent libc++.dylib but running the tests against an
older version (the back-deployment use case).

llvm-svn: 349171

2 years ago[Transforms] Preserve metadata when converting invoke to call.
Michael Kruse [Fri, 14 Dec 2018 18:15:11 +0000 (18:15 +0000)]
[Transforms] Preserve metadata when converting invoke to call.

The `changeToCall` function did not preserve the invoke's metadata.
Currently, there is probably no metadata that depends on being applied
on a CallInst or InvokeInst. Therefore we can replace the instruction's
metadata.

This fixes http://llvm.org/PR39994

Suggested-by: Moritz Kreutzer <moritz.kreutzer@siemens.com>
Differential Revision: https://reviews.llvm.org/D55666

llvm-svn: 349170

2 years ago[MS Demangler] Fail gracefully on invalid pointer types.
Zachary Turner [Fri, 14 Dec 2018 18:10:13 +0000 (18:10 +0000)]
[MS Demangler] Fail gracefully on invalid pointer types.

Once we detect a 'P', we know we a pointer type is upcoming, so
we make some assumptions about the output that follows.  If those
assumptions didn't hold, we would assert.  Instead, we should
fail gracefully and propagate the error up.

llvm-svn: 349169

2 years ago[MS Demangler] Add a regression test for an invalid mangled name.
Zachary Turner [Fri, 14 Dec 2018 17:59:27 +0000 (17:59 +0000)]
[MS Demangler] Add a regression test for an invalid mangled name.

llvm-svn: 349168

2 years ago[globalisel][combiner] Make the CombinerChangeObserver a MachineFunction::Delegate
Daniel Sanders [Fri, 14 Dec 2018 17:50:14 +0000 (17:50 +0000)]
[globalisel][combiner] Make the CombinerChangeObserver a MachineFunction::Delegate

Summary:
This allows us to register it with the MachineFunction delegate and be
notified automatically about erasure and creation of instructions. However,
we still need explicit notification for modifications such as those caused
by setReg() or replaceRegWith().

There is a catch with this though. The notification for creation is
delivered before any operands can be added. While appropriate for
scheduling combiner work. This is unfortunate for debug output since an
opcode by itself doesn't provide sufficient information on what happened.
As a result, the work list remembers the instructions (when debug output is
requested) and emits a more complete dump later.

Another nit is that the MachineFunction::Delegate provides const pointers
which is inconvenient since we want to use it to schedule future
modification. To resolve this GISelWorkList now has an optional pointer to
the MachineFunction which describes the scope of the work it is permitted
to schedule. If a given MachineInstr* is in this function then it is
permitted to schedule work to be performed on the MachineInstr's. An
alternative to this would be to remove the const from the
MachineFunction::Delegate interface, however delegates are not permitted
to modify the MachineInstr's they receive.

In addition to this, the observer has three interface changes.
* erasedInstr() is now erasingInstr() to indicate it is about to be erased
  but still exists at the moment.
* changingInstr() and changedInstr() have been added to report changes
  before and after they are made. This allows us to trace the changes
  in the debug output.
* As a convenience changingAllUsesOfReg() and
  finishedChangingAllUsesOfReg() will report changingInstr() and
  changedInstr() for each use of a given register. This is primarily useful
  for changes caused by MachineRegisterInfo::replaceRegWith()

With this in place, both combine rules have been updated to report their
changes to the observer.

Finally, make some cosmetic changes to the debug output and make Combiner
and CombinerHelp

Reviewers: aditya_nandakumar, bogner, volkan, rtereshin, javed.absar

Reviewed By: aditya_nandakumar

Subscribers: mgorny, rovka, kristof.beyls, llvm-commits

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

llvm-svn: 349167

2 years ago[AArch64] make test immune to scalarization improvements; NFC
Sanjay Patel [Fri, 14 Dec 2018 17:44:07 +0000 (17:44 +0000)]
[AArch64] make test immune to scalarization improvements; NFC

This is explicitly implementing what the comment says rather
than relying on the implicit zext of a costant operand.

llvm-svn: 349166

2 years agoFix a crash in llvm-undname with invalid types.
Zachary Turner [Fri, 14 Dec 2018 17:43:56 +0000 (17:43 +0000)]
Fix a crash in llvm-undname with invalid types.

llvm-svn: 349165

2 years ago[SystemZ] make test immune to scalarization improvements; NFC
Sanjay Patel [Fri, 14 Dec 2018 17:28:52 +0000 (17:28 +0000)]
[SystemZ] make test immune to scalarization improvements; NFC

The undef operands mean this test is probably still too fragile
to accomplish what the comments suggest.

llvm-svn: 349164

2 years ago[Hexagon] make test immune to scalarization improvements; NFC
Sanjay Patel [Fri, 14 Dec 2018 17:23:01 +0000 (17:23 +0000)]
[Hexagon] make test immune to scalarization improvements; NFC

llvm-svn: 349163

2 years ago[x86] auto-generate complete checks; NFC
Sanjay Patel [Fri, 14 Dec 2018 16:49:57 +0000 (16:49 +0000)]
[x86] auto-generate complete checks; NFC

llvm-svn: 349162

2 years ago[x86] regenerate test checks; NFC
Sanjay Patel [Fri, 14 Dec 2018 16:46:21 +0000 (16:46 +0000)]
[x86] regenerate test checks; NFC

llvm-svn: 349161

2 years ago[x86] make tests immune to scalarization improvements; NFC
Sanjay Patel [Fri, 14 Dec 2018 16:44:58 +0000 (16:44 +0000)]
[x86] make tests immune to scalarization improvements; NFC

llvm-svn: 349160

2 years agoMark interception_failure_test.cc as passing for NetBSD and asan-dynamic-runtime
Kamil Rytarowski [Fri, 14 Dec 2018 16:26:09 +0000 (16:26 +0000)]
Mark interception_failure_test.cc as passing for NetBSD and asan-dynamic-runtime

llvm-svn: 349159

2 years agoNFC. Adding an empty line to test the updated commit credentials.
Ehsan Amiri [Fri, 14 Dec 2018 16:19:02 +0000 (16:19 +0000)]
NFC. Adding an empty line to test the updated commit credentials.

llvm-svn: 349158

2 years agoMove Broadcaster+Listener+Event combo from Core into Utility
Pavel Labath [Fri, 14 Dec 2018 15:59:49 +0000 (15:59 +0000)]
Move Broadcaster+Listener+Event combo from Core into Utility

Summary:
These are general purpose "utility" classes, whose functionality is not
debugger-specific in any way. As such, I believe they belong in the
Utility module.

This doesn't break any particular dependency (yet), but it reduces the
number of Core dependencies across the board.

Reviewers: zturner, jingham, teemperor, clayborg

Subscribers: mgorny, lldb-commits

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

llvm-svn: 349157

2 years agoSet shared_libasan_path in lit tests for NetBSD
Kamil Rytarowski [Fri, 14 Dec 2018 15:58:05 +0000 (15:58 +0000)]
Set shared_libasan_path in lit tests for NetBSD

Reuse the Linux code path.

llvm-svn: 349156

2 years agoImplement -frecord-command-line (-frecord-gcc-switches)
Scott Linder [Fri, 14 Dec 2018 15:38:15 +0000 (15:38 +0000)]
Implement -frecord-command-line (-frecord-gcc-switches)

Implement options in clang to enable recording the driver command-line
in an ELF section.

Implement a new special named metadata, llvm.commandline, to support
frontends embedding their command-line options in IR/ASM/ELF.

This differs from the GCC implementation in some key ways:

* In GCC there is only one command-line possible per compilation-unit,
  in LLVM it mirrors llvm.ident and multiple are allowed.
* In GCC individual options are separated by NULL bytes, in LLVM entire
  command-lines are separated by NULL bytes. The advantage of the GCC
  approach is to clearly delineate options in the face of embedded
  spaces. The advantage of the LLVM approach is to support merging
  multiple command-lines unambiguously, while handling embedded spaces
  with escaping.

Differential Revision: https://reviews.llvm.org/D54487
Clang Differential Revision: https://reviews.llvm.org/D54489

llvm-svn: 349155

2 years agoFix minidump unit test failures from r349062
Pavel Labath [Fri, 14 Dec 2018 14:41:04 +0000 (14:41 +0000)]
Fix minidump unit test failures from r349062

This commit added new test inputs, but it did not add them to the cmake
files. This caused the test to fail at runtime.

While in there, I also sorted the list of minidump test inputs.

llvm-svn: 349154

2 years agoFix build with older (<3.0) swigs
Pavel Labath [Fri, 14 Dec 2018 14:25:20 +0000 (14:25 +0000)]
Fix build with older (<3.0) swigs

It turns out it wasn't the compilers, but swig who had issues with my
previous patch -- older versions do not recognise the "constexpr"
keyword.

Fortunately, that can be fixed the same way we fix all other swig
incompatibilities: #ifndef SWIG.

llvm-svn: 349153