platform/upstream/llvm.git
4 years agoRevert "[Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy"
Tom Stellard [Mon, 25 Nov 2019 20:23:32 +0000 (12:23 -0800)]
Revert "[Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy"

This reverts commit 9353c5dd0664ea444236e527bf93566e11dc34df.

This commit introduced bot falures for multi-stage bots with -Werror.

4 years agoRevert "[DDG] Data Dependence Graph - Topological Sort"
Bardia Mahjour [Mon, 25 Nov 2019 21:17:41 +0000 (16:17 -0500)]
Revert "[DDG] Data Dependence Graph - Topological Sort"
Revert for now to look into the failures  on x86

This reverts commit bec37c3fc766a7b97f8c52c181c325fd47b75259.

4 years ago[PowerPC][compiler-rt][builtins]Add __fixtfti builtin on PowerPC
Lei Huang [Mon, 25 Nov 2019 20:06:21 +0000 (14:06 -0600)]
[PowerPC][compiler-rt][builtins]Add __fixtfti builtin on PowerPC

Implements __fixtfti builtin for PowerPC. This builtin converts a
long double (IBM double-double) to a signed int128. The conversion relies on
the unsigned conversion of the absolute value of the long double.

Tests included for both positive and negative long doubles.

Patch By: Baptiste Saleil

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

4 years ago[GWP-ASan] Add GWP_ASAN_ prefix to macros.
Mitch Phillips [Mon, 25 Nov 2019 20:25:43 +0000 (12:25 -0800)]
[GWP-ASan] Add GWP_ASAN_ prefix to macros.

Summary:
When platforms use their own `LIKELY()` definitions, it can be quite
troublesome to ensure they don't conflict with the GWP-ASan internal
definitions. Just force the GWP_ASAN_ prefix to help this issue.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: #sanitizers, llvm-commits, cferris, pcc

Tags: #sanitizers, #llvm

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

4 years ago[PowerPC] Rename DarwinDirective to CPUDirective (NFC)
Kit Barton [Fri, 15 Nov 2019 21:48:34 +0000 (15:48 -0600)]
[PowerPC] Rename DarwinDirective to CPUDirective (NFC)

Summary:
This patch renames the DarwinDirective (used to identify which CPU was defined)
to CPUDirective. It also adds the getCPUDirective() method and replaces all uses
of getDarwinDirective() with getCPUDirective().

Once this patch lands and downstream users of the getDarwinDirective() method
have switched to the getCPUDirective() method, the old getDarwinDirective()
method will be removed.

Reviewers: nemanjai, hfinkel, power-llvm-team, jsji, echristo, #powerpc, jhibbits

Reviewed By: hfinkel, jsji, jhibbits

Subscribers: hiraditya, shchenz, llvm-commits

Tags: #llvm

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

4 years ago[LLD] Add a default copy constructor to avoid warnings
Nemanja Ivanovic [Mon, 25 Nov 2019 20:07:57 +0000 (14:07 -0600)]
[LLD] Add a default copy constructor to avoid warnings

This should fix the failure on the PPC64LE LLD bot.

4 years ago[OPENMP]Fix PR41826: symbols visibility in device code.
Alexey Bataev [Thu, 21 Nov 2019 16:30:43 +0000 (11:30 -0500)]
[OPENMP]Fix PR41826: symbols visibility in device code.

Summary:
Currently, we ignore all locality attributes/info when building for
the device and thus all symblos are externally visible and can be
preemted at the runtime. It may lead to incorrect results. We need to
follow the same logic, compiler uses for static/pie builds. But in some
cases changing of dso locality may lead to problems with codegen, so
instead mark external symbols as hidden instead in the device code.

Reviewers: jdoerfert

Subscribers: guansong, caomhin, kkwli0, cfe-commits

Tags: #clang

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

4 years ago[Diagnostic] add a warning which warns about misleading indentation
Tyker [Mon, 25 Nov 2019 19:46:32 +0000 (20:46 +0100)]
[Diagnostic] add a warning which warns about misleading indentation

Summary: Add a warning for misleading indentation similar to GCC's -Wmisleading-indentation

Reviewers: aaron.ballman, xbolva00

Reviewed By: aaron.ballman, xbolva00

Subscribers: arphaman, Ka-Ka, thakis

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

4 years ago[lldb] [Process/NetBSD] Fix handling concurrent watchpoint events
Michał Górny [Fri, 8 Nov 2019 17:42:37 +0000 (18:42 +0100)]
[lldb] [Process/NetBSD] Fix handling concurrent watchpoint events

Fix handling concurrent watchpoint events so that they are reported
correctly in LLDB.

If multiple watchpoints are hit concurrently, the NetBSD kernel reports
them as series of SIGTRAPs with a thread specified, and the debugger
investigates DR6 in order to establish which watchpoint was hit.  This
is normally fine.

However, LLDB disables and reenables the watchpoint on all threads after
each hit, which results in the hit status from DR6 being wiped.
As a result, it can't establish which watchpoint was hit in successive
SIGTRAP processing.

In order to workaround this problem, clear DR6 only if the breakpoint
is overwritten with a new one.  More specifically, move cleaning DR6
from ClearHardwareWatchpoint() to SetHardwareWatchpointWithIndex(),
and do that only if the newly requested watchpoint is different
from the one being set previously.  This ensures that the disable-enable
logic of LLDB does not clear watchpoint hit status for the remaining
threads.

This also involves refactoring of watchpoint logic.  With the old logic,
clearing watchpoint involved wiping dr6 & dr7, and setting it setting
dr{0..3} & dr7.  With the new logic, only enable bit is cleared
from dr7, and the remaining bits are cleared/overwritten while setting
new watchpoint.

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

4 years ago[lldb] [Process/NetBSD] Copy watchpoints to newly-created threads
Michał Górny [Sat, 9 Nov 2019 10:56:08 +0000 (11:56 +0100)]
[lldb] [Process/NetBSD] Copy watchpoints to newly-created threads

NetBSD ptrace interface does not populate watchpoints to newly-created
threads.  Solve this via copying the watchpoints from the current thread
when new thread is reported via TRAP_LWP.

Add a test that verifies that when the user does not have permissions
to set watchpoints on NetBSD, the 'watchpoint set' errors out gracefully
and thread monitoring does not crash on being unable to copy watchpoints
to new threads.

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

4 years ago[lldb] [Process/NetBSD] Improve threading support
Michał Górny [Fri, 12 Jul 2019 17:11:31 +0000 (19:11 +0200)]
[lldb] [Process/NetBSD] Improve threading support

Implement major improvements to multithreaded program support.  Notably,
support tracking new and exited threads, associate signals and events
with correct threads and support controlling individual threads when
resuming.

Firstly, use PT_SET_EVENT_MASK to enable reporting of created and exited
threads via SIGTRAP.  Handle TRAP_LWP events to keep track
of the currently running threads.

Secondly, update the signal (both generic and SIGTRAP) handling code
to account for per-thread signals correctly.  Signals delivered
to the whole process are reported on all threads, while per-thread
signals and events are reported only to the specific thread.
The remaining threads are marked as 'stopped with no reason'.  Note that
NetBSD always stops all threads on debugger events.

Thirdly, implement the ability to set every thread as running, stopped
or single-stepping separately while continuing the process.  This also
provides the ability to send a signal to the whole process or to one
of its thread while resuming.

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

4 years ago[libcxx] Omit unneeded locale fallbacks on Android 21+
Shoaib Meenai [Fri, 8 Nov 2019 03:55:58 +0000 (19:55 -0800)]
[libcxx] Omit unneeded locale fallbacks on Android 21+

Android API level 21 and above have all these functions available, so we
don't need to include our fallback definitions.

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

4 years ago[lldb] [test] XFAIL ASAN tests on NetBSD
Michał Górny [Mon, 25 Nov 2019 19:03:41 +0000 (20:03 +0100)]
[lldb] [test] XFAIL ASAN tests on NetBSD

4 years ago[TargetLowering] Merge ExpandChainLibCall with makeLibCall
Craig Topper [Mon, 25 Nov 2019 18:48:28 +0000 (10:48 -0800)]
[TargetLowering] Merge ExpandChainLibCall with makeLibCall

I need to be able to drop an operand for STRICT_FP_ROUND handling on X86. Merging these functions gives me the ArrayRef interface that passes the return type, operands, and debugloc instead of the Node.

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

4 years ago[InstCombine] remove shuffle mask canonicalization that creates undef elements
Sanjay Patel [Mon, 25 Nov 2019 18:30:45 +0000 (13:30 -0500)]
[InstCombine] remove shuffle mask canonicalization that creates undef elements

This is NFC-intended because SimplifyDemandedVectorElts() does the same
transform later. As discussed in D70641, we may want to change that
behavior, so we need to isolate where it happens.

4 years ago[WebAssembly] Change the llvm-lto dir to use the LLVM Version
Dan Gohman [Mon, 25 Nov 2019 17:28:31 +0000 (09:28 -0800)]
[WebAssembly] Change the llvm-lto dir to use the LLVM Version

Using the version instead of the VCS revision, which isn't available
when LLVM_APPEND_VC_REV is set. The bitcode format should be
backwards-compatible at least within a minor version, so the version
string should be sufficient.

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

4 years ago[ARM] Generate CMSE instructions from CMSE intrinsics
Momchil Velikov [Mon, 18 Nov 2019 18:03:41 +0000 (18:03 +0000)]
[ARM] Generate CMSE instructions from CMSE intrinsics

This patch adds instruction selection patterns for the TT, TTT, TTA, and TTAT
instructions and tests for llvm.arm.cmse.tt, llvm.arm.cmse.ttt,
llvm.arm.cmse.tta, and llvm.arm.cmse.ttat intrinsics (added in a previous
patch).

Patch by Javed Absar.

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

4 years ago[SystemZ] Return the right offsets from getCalleeSavedSpillSlots().
Jonas Paulsson [Mon, 25 Nov 2019 17:48:47 +0000 (18:48 +0100)]
[SystemZ]  Return the right offsets from getCalleeSavedSpillSlots().

// Due to the SystemZ ABI, the DWARF CFA (Canonical Frame Address) is not
// equal to the incoming stack pointer, but to incoming stack pointer plus
// 160.  The getOffsetOfLocalArea() returned value is interpreted as "the
// offset of the local area from the CFA".

The immediate offsets into the Register save area returned by
getCalleeSavedSpillSlots() should take this offset into account, which this
patch makes sure of.

Patch and review by Ulrich Weigand.
https://reviews.llvm.org/D70427

4 years ago[NFC][LoopFusion] Use isControlFlowEquivalent() from CodeMoverUtils.
Whitney Tsang [Mon, 25 Nov 2019 17:51:24 +0000 (17:51 +0000)]
[NFC][LoopFusion] Use isControlFlowEquivalent() from CodeMoverUtils.
Reviewer: kbarton, jdoerfert, Meinersbur, bmahjour, etiotto
Reviewed By: Meinersbur
Subscribers: hiraditya, llvm-commits
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D70619

4 years ago[PowerPC] Fix VSX clobbers of CSR registers
Nemanja Ivanovic [Mon, 25 Nov 2019 15:32:28 +0000 (09:32 -0600)]
[PowerPC] Fix VSX clobbers of CSR registers

If an inline asm statement clobbers a VSX register that overlaps with a
callee-saved Altivec register or FPR, we will not record the clobber and will
therefore violate the ABI. This is clearly a bug so this patch fixes it.

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

4 years ago[InstCombine] prevent infinite loop from conflicting shuffle mask transforms
Sanjay Patel [Mon, 25 Nov 2019 16:55:57 +0000 (11:55 -0500)]
[InstCombine] prevent infinite loop from conflicting shuffle mask transforms

The pattern in question is currently not possible because we
aggressively (wrongly) transform mask elements to undef values
if they choose from an undef operand. That, however, would
change if we tighten our semantics for shuffles as discussed
in D70641. Adding this check gives us the flexibility to make
that change with minimal overhead for current definitions.

4 years ago[scudo][standalone] Fix for releaseToOS prior to init
Kostya Kortchinsky [Thu, 21 Nov 2019 18:57:49 +0000 (10:57 -0800)]
[scudo][standalone] Fix for releaseToOS prior to init

Summary:
cferris@ found an issue where calling `releaseToOS` prior to any other
heap operation would lead to a crash, due to the allocator not being
properly initialized (it was discovered via `mallopt`).

The fix is to call `initThreadMaybe` prior to calling `releaseToOS` for
the Primary.

Add a test that crashes prior to fix.

Reviewers: hctim, cferris, pcc, eugenis

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[DDG] Data Dependence Graph - Topological Sort
bmahjour [Mon, 25 Nov 2019 16:12:37 +0000 (11:12 -0500)]
[DDG] Data Dependence Graph - Topological Sort

Summary:
In this patch the DDG DAG is sorted topologically to put the
nodes in the graph in the order that would satisfy all
dependencies. This helps transformations that would like to
generate code based on the DDG. Since the DDG is a DAG a
reverse-post-order traversal would give us the topological
ordering. This patch also sorts the basic blocks passed to
the builder based on program order to ensure that the
dependencies are computed in the correct direction.

Authored By: bmahjour

Reviewer: Meinersbur, fhahn, myhsu, xtian, dmgreen, kbarton, jdoerfert

Reviewed By: Meinersbur

Subscribers: ychen, arphaman, simoll, a.elovikov, mgorny, hiraditya, jfb, wuzish, llvm-commits, jsji, Whitney, etiotto, ppc-slack

Tags: #llvm

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

4 years ago[InstCombine] simplify code for shuffle mask canonicalization; NFC
Sanjay Patel [Mon, 25 Nov 2019 16:11:12 +0000 (11:11 -0500)]
[InstCombine] simplify code for shuffle mask canonicalization; NFC

We never use the local 'Mask' before returning, so that was dead code.

4 years ago[InstCombine] remove dead code from shuffle mask canonicalization; NFC
Sanjay Patel [Mon, 25 Nov 2019 15:54:18 +0000 (10:54 -0500)]
[InstCombine] remove dead code from shuffle mask canonicalization; NFC

4 years ago[InstCombine] simplify loop for shuffle mask canonicalization; NFC
Sanjay Patel [Mon, 25 Nov 2019 15:40:21 +0000 (10:40 -0500)]
[InstCombine] simplify loop for shuffle mask canonicalization; NFC

4 years agoRevert 3f91705ca54 "ARM-NEON: make type modifiers orthogonal and allow multiple modif...
Hans Wennborg [Mon, 25 Nov 2019 15:27:53 +0000 (16:27 +0100)]
Revert 3f91705ca54 "ARM-NEON: make type modifiers orthogonal and allow multiple modifiers."

This broke the vcreate_u64 intrinsic. Example:

  $ cat /tmp/a.cc
  #include <arm_neon.h>

  void g() {
    auto v = vcreate_u64(0);
  }
  $ bin/clang -c /tmp/a.cc --target=arm-linux-androideabi16 -march=armv7-a
  /tmp/a.cc:4:12: error: C-style cast from scalar 'int' to vector 'uint64x1_t' (vector of 1 'uint64_t' value) of different size
    auto v = vcreate_u64(0);
             ^~~~~~~~~~~~~~
  /work/llvm.monorepo/build.release/lib/clang/10.0.0/include/arm_neon.h:4144:11: note: expanded from macro 'vcreate_u64'
    __ret = (uint64x1_t)(__p0); \
            ^~~~~~~~~~~~~~~~~~

Reverting until this can be investigated.

> The modifier system used to mutate types on NEON intrinsic definitions had a
> separate letter for all kinds of transformations that might be needed, and we
> were quite quickly running out of letters to use. This patch converts to a much
> smaller set of orthogonal modifiers that can be applied together to achieve the
> desired effect.
>
> When merging with downstream it is likely to cause a conflict with any local
> modifications to the .td files. There is a new script in
> utils/convert_arm_neon.py that was used to convert all .td definitions and I
> would suggest running it on the last downstream version of those files before
> this commit rather than resolving conflicts manually.

4 years ago[AMDGPU] Fix function name in debug output
Jay Foad [Mon, 25 Nov 2019 15:21:18 +0000 (15:21 +0000)]
[AMDGPU] Fix function name in debug output

4 years ago[AIX][XCOFF] Generate undefined symbol in symbol table for external function call
jasonliu [Mon, 25 Nov 2019 15:02:01 +0000 (15:02 +0000)]
[AIX][XCOFF] Generate undefined symbol in symbol table for external function call

Summary:
This patch sets up the infrastructure for

 1. Associate MCSymbolXCOFF with an MCSectionXCOFF when it could not
    get implicitly associated.
 2. Generate undefined symbols. The patch itself generates undefined symbol
    for external function call only. Generate undefined symbol for external
    global variable and external function descriptors will be handled in
    separate patch(s) after this is land.

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

4 years ago[lldb][NFC] Allow range-based for-loops on VariableList
Raphael Isemann [Mon, 25 Nov 2019 14:03:46 +0000 (15:03 +0100)]
[lldb][NFC] Allow range-based for-loops on VariableList

Summary:
Adds support for doing range-based for-loops on LLDB's VariableList and
modernises all the index-based for-loops in LLDB where possible.

Reviewers: labath, jdoerfert

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

4 years ago[DebugInfo] Avoid register coalesing unsoundly changing DBG_VALUE locations
Jeremy Morse [Mon, 25 Nov 2019 13:38:27 +0000 (13:38 +0000)]
[DebugInfo] Avoid register coalesing unsoundly changing DBG_VALUE locations

This is a re-land of D56151 / r364515 with a completely new implementation.

Once MIR code leaves SSA form and the liveness of a vreg is considered,
DBG_VALUE insts are able to refer to non-live vregs, because their
debug-uses do not contribute to liveness. This non-liveness becomes
problematic for optimizations like register coalescing, as they can't
``see'' the debug uses in the liveness analyses.

As a result registers get coalesced regardless of debug uses, and that can
lead to invalid variable locations containing unexpected values. In the
added test case, the first vreg operand of ADD32rr is merged with various
copies of the vreg (great for performance), but a DBG_VALUE of the
unmodified operand is blindly updated to the modified operand. This changes
what value the variable will appear to have in a debugger.

Fix this by changing any DBG_VALUE whose operand will be resurrected by
register coalescing to be a $noreg DBG_VALUE, i.e. give the variable no
location. This is an overapproximation as some coalesced locations are safe
(others are not) -- an extra domination analysis would be required to work
out which, and it would be better if we just don't generate non-live
DBG_VALUEs.

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

4 years ago[lldb] Remove lldb's own ASTDumper
Raphael Isemann [Mon, 25 Nov 2019 12:27:51 +0000 (13:27 +0100)]
[lldb] Remove lldb's own ASTDumper

Summary:
LLDB's ASTDumper is just a clone of Clang's ASTDumper but with some scary code and
some unrelated functionality (like dumping name/attributes of types). This removes LLDB's ASTDumper
and replaces its uses with the `ClangUtils::DumpDecl` method that just calls Clang's ASTDumper
and returns the result as a string.

The few uses where we just want a textual representation of a type (which will print their name/attributes but not
dump any AST) are now also in ClangUtil under a `ToString` name until we find a better home for them.

Reviewers: labath

Reviewed By: labath

Subscribers: mgorny, JDevlieghere, lldb-commits

Tags: #lldb

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

4 years ago[ARM][MVE] Select vqneg
Anna Welker [Mon, 25 Nov 2019 11:17:13 +0000 (11:17 +0000)]
[ARM][MVE] Select vqneg

Adds a pattern to ARMInstrMVE.td to use a VQNEG
  instruction if an equivalent multi-instruction
  construct is found.

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

4 years ago[DebugInfo@O2][Utils] Undef instead of delete dbg.values in helper func
OCHyams [Mon, 25 Nov 2019 09:02:05 +0000 (09:02 +0000)]
[DebugInfo@O2][Utils] Undef instead of delete dbg.values in helper func

Summary:
Related bug: https://bugs.llvm.org/show_bug.cgi?id=40648

Static helper function rewriteDebugUsers in Local.cpp deletes dbg.value
intrinsics when it cannot move or rewrite them, or salvage the deleted
instruction's value. It should instead undef them in this case.

This patch fixes that and I've added a test which covers the failing test
case in bz40648. I've updated the unit test Local.ReplaceAllDbgUsesWith
to check for this behaviour (and fixed a typo in the test which would
cause the old test to always pass).

Reviewers: aprantl, vsk, djtodoro, probinson

Reviewed By: vsk

Subscribers: hiraditya, llvm-commits

Tags: #debug-info, #llvm

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

4 years ago[AVR] Fix endianness handling in AVR MC
serge_sans_paille [Tue, 24 Sep 2019 08:20:08 +0000 (10:20 +0200)]
[AVR] Fix endianness handling in AVR MC

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

4 years ago[yaml2obj/obj2yaml] - Add support for SHT_LLVM_DEPENDENT_LIBRARIES sections.
Georgii Rymar [Fri, 22 Nov 2019 14:18:34 +0000 (17:18 +0300)]
[yaml2obj/obj2yaml] - Add support for SHT_LLVM_DEPENDENT_LIBRARIES sections.

This section contains strings specifying libraries to be added to the link by the linker.
The strings are encoded as standard null-terminated UTF-8 strings.

This patch adds a way to describe and dump SHT_LLVM_DEPENDENT_LIBRARIES sections.

I introduced a new YAMLFlowString type here. That used to teach obj2yaml to dump
them like:

```
Libraries: [ foo, bar ]
```

instead of the following (if StringRef would be used):

```
Libraries:
  - foo
  - bar
```

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

4 years ago[clangd] Fix diagnostic location for macro expansions
Kadir Cetinkaya [Wed, 20 Nov 2019 15:17:03 +0000 (16:17 +0100)]
[clangd] Fix diagnostic location for macro expansions

Summary:
Diagnostic locations were broken when it was result of a macro
expansion. This patch fixes it by using expansion location instead of location
inside macro body.

Fixes https://github.com/clangd/clangd/issues/201.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[clangd] Improve symbol qualification in DefineInline code action
Kadir Cetinkaya [Tue, 1 Oct 2019 08:58:35 +0000 (10:58 +0200)]
[clangd] Improve symbol qualification in DefineInline code action

Summary:
Currently define inline action fully qualifies any names in the
function body, which is not optimal and definitely natural.

This patch tries to improve the situation by dropping any name
specifiers shared by function and names spelled in the body. For example
if you are moving definition of a function in namespace clang::clangd,
and body has any decl's coming from clang or clang::clangd namespace,
those qualifications won't be added since they are redundant.

It also drops any qualifiers that are visible in target context.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[clangd] Helper for getting nested namespace qualification
Kadir Cetinkaya [Wed, 30 Oct 2019 08:04:10 +0000 (09:04 +0100)]
[clangd] Helper for getting nested namespace qualification

Summary:
Introduce a new helper for getting minimally required qualifiers
necessary to spell a name at a point in a given DeclContext. Currently takes
using directives and nested namespecifier of DeclContext itself into account.

Initially will be used in define inline and outline actions.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[lldb-vscode] Fix a race in test_extra_launch_commands
Pavel Labath [Tue, 12 Nov 2019 16:28:42 +0000 (17:28 +0100)]
[lldb-vscode] Fix a race in test_extra_launch_commands

Summary:
The test used a non-stopping "run" command to launch the process. This
is different from the regular launch with no extra launch commands,
which uses eLaunchFlagStopAtEntry to ensure that the process stops
straight away.

I'm not really sure what's supposed to happen in non-stop-at-entry mode,
or if that's even supported, but what ended up happening was the launch
packet got a reply while the process was running. Then the test case did
a continue_to_next_stop(), which queued a *second* resume request
(along with the internal "resumes" which were being issued as a part of
normal process startup). These two resumes ended up chasing each other's
tails inside lldb in a way which produced hilarious log traces.
Surprisingly, the test ended up passing most of the time, but it did
cause spurious failures when the test seemed to miss a breakpoint.

This changes the test to use stop-at-entry mode in the manual launch
sequence too, which seems to be enough to make the test pass reliably.

Reviewers: clayborg, kusmour, jankratochvil

Subscribers: lldb-commits

Tags: #lldb

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

4 years ago[NFC][Test] Adding the test for bswap + logic op for PowerPC
QingShan Zhang [Mon, 25 Nov 2019 08:21:12 +0000 (08:21 +0000)]
[NFC][Test] Adding the test for bswap + logic op for PowerPC

4 years ago[X86] Add 32-bit RUN line to fp128-libcalls.ll. Add nounwind to test functions. NFC
Craig Topper [Mon, 25 Nov 2019 05:58:57 +0000 (21:58 -0800)]
[X86] Add 32-bit RUN line to fp128-libcalls.ll. Add nounwind to test functions. NFC

4 years agoRevert "[PowerPC] combine rlwinm+rlwinm to rlwinm"
czhengsz [Mon, 25 Nov 2019 03:46:26 +0000 (22:46 -0500)]
Revert "[PowerPC] combine rlwinm+rlwinm to rlwinm"

This reverts commit 29f6f9b2b2bfecccf903738e2f5a0cd0a70fce31.

4 years ago[llvm-objcopy][MachO] Implement --dump-section
Seiya Nuta [Mon, 25 Nov 2019 03:29:58 +0000 (12:29 +0900)]
[llvm-objcopy][MachO] Implement --dump-section

Reviewers: alexshap, rupprecht, jhenderson

Reviewed By: alexshap, rupprecht, jhenderson

Subscribers: MaskRay, jakehehrlich, abrachet, llvm-commits

Tags: #llvm

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

4 years ago[CMake] Use correct include path for InstrProfData.inc on Darwin
Petr Hosek [Sun, 24 Nov 2019 21:23:30 +0000 (13:23 -0800)]
[CMake] Use correct include path for InstrProfData.inc on Darwin

On Darwin, part of the profile runtime is included in the builtin
library. f35032e changed the location of InstrProfData.inc but the
builtin build for Darwin hasn't been updated to include the new
path which causes a breakage when building for Darwin. This change
addresses this breakage.

4 years agoRecommit f0c2a5a "[LV] Generalize conditions for sinking instrs for first order recur...
Florian Hahn [Sun, 24 Nov 2019 20:43:12 +0000 (20:43 +0000)]
Recommit f0c2a5a "[LV] Generalize conditions for sinking instrs for first order recurrences."

This version contains 2 fixes for reported issues:
1. Make sure we do not try to sink terminator instructions.
2. Make sure we bail out, if we try to sink an instruction that needs to
   stay in place for another recurrence.

Original message:
If the recurrence PHI node has a single user, we can sink any
instruction without side effects, given that all users are dominated by
the instruction computing the incoming value of the next iteration
('Previous'). We can sink instructions that may cause traps, because
that only causes the trap to occur later, but not on any new paths.

With the relaxed check, we also have to make sure that we do not have a
direct cycle (meaning PHI user == 'Previous), which indicates a
reduction relation, which potentially gets missed by
ReductionDescriptor.

As follow-ups, we can also sink stores, iff they do not alias with
other instructions we move them across and we could also support sinking
chains of instructions and multiple users of the PHI.

Fixes PR43398.

Reviewers: hsaito, dcaballe, Ayal, rengolin

Reviewed By: Ayal

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

4 years ago[mips] Split test into MIPS and microMIPS parts. NFC
Simon Atanasyan [Thu, 21 Nov 2019 18:48:15 +0000 (21:48 +0300)]
[mips] Split test into MIPS and microMIPS parts. NFC

4 years ago[LoopInterchange] Adjust assertions when updating successors.
Florian Hahn [Sun, 24 Nov 2019 19:24:10 +0000 (19:24 +0000)]
[LoopInterchange] Adjust assertions when updating successors.

Currently the assertion in updateSuccessor is overly strict in some
cases and overly relaxed in other cases. For branches to the inner and
outer loop preheader it is too strict, because they can either be
unconditional branches or conditional branches with duplicate targets.
Both cases are fine and we can allow updating multiple successors.

On the other hand, we have to at least update one successor. This patch
adds such an assertion.

4 years ago[TableGen] Fixed 'unused but set variable' warning. NFCI
Dávid Bolvanský [Sun, 24 Nov 2019 19:04:03 +0000 (20:04 +0100)]
[TableGen] Fixed 'unused but set variable' warning. NFCI

4 years ago[Diagnostics] Warn for comparison with string literals expanded from macro (PR44064)
Dávid Bolvanský [Sun, 24 Nov 2019 15:30:45 +0000 (16:30 +0100)]
[Diagnostics] Warn for comparison with string literals expanded from macro (PR44064)

Summary:
As noted in PR, we have a poor test coverage for this warning. I think macro support was just overlooked. GCC warns in these cases.
Clang missed a real bug in the code I am working with, GCC caught it.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[InstCombine] remove identity shuffle simplification for mask with undefs
Sanjay Patel [Sun, 24 Nov 2019 15:06:26 +0000 (10:06 -0500)]
[InstCombine] remove identity shuffle simplification for mask with undefs

And simultaneously enhance SimplifyDemandedVectorElts() to rcognize that
pattern. That preserves some of the old optimizations in IR.

Given a shuffle that includes undef elements in an otherwise identity mask like:

define <4 x float> @shuffle(<4 x float> %arg) {
  %shuf = shufflevector <4 x float> %arg, <4 x float> undef, <4 x i32> <i32 undef, i32 1, i32 2, i32 3>
  ret <4 x float> %shuf
}

We were simplifying that to the input operand.

But as discussed in PR43958:
https://bugs.llvm.org/show_bug.cgi?id=43958
...that means that per-vector-element poison that would be stopped by the shuffle can now
leak to the result.

Also note that we still have (and there are tests for) the same transform with no undef
elements in the mask (a fully-defined identity mask). I don't think there's any
controversy about that case - it's a valid transform under any interpretation of
shufflevector/undef/poison.

Looking at a few of the diffs into codegen, I don't see any difference in final asm. So
depending on your perspective, that's good (no real loss of optimization power) or bad
(poison exists in the DAG, so we only partially fixed the bug).

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

4 years agoFixed -Wdeprecated-copy warnings in gtest. NFCI.
Dávid Bolvanský [Sun, 24 Nov 2019 08:42:07 +0000 (09:42 +0100)]
Fixed -Wdeprecated-copy warnings in gtest. NFCI.

4 years ago[PowerPC] Spill CR LT bits on P9 using setb
Amy Kwan [Sun, 24 Nov 2019 06:27:40 +0000 (00:27 -0600)]
[PowerPC] Spill CR LT bits on P9 using setb

This patch aims to spill CR[0-7]LT bits on POWER9 using the setb instruction.
The sequence on P9 to spill these bits will be:

setb %reg, %CRREG
stw %reg, $FI

Instead of the typical sequence:

mfocrf %reg, %CRREG
rlwinm %reg1, %reg, $SH, 0, 0
stw %reg1, $FI

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

4 years ago[ModuloSchedule] Fix a bug in experimental expander
Thomas Raoux [Thu, 14 Nov 2019 17:55:02 +0000 (09:55 -0800)]
[ModuloSchedule] Fix a bug in experimental expander

Fix two problems that popped up after my last patch. One is that the
stiching of prologue/epilogue can be wrong when reading a value from a
previsou stage. Also changed how we duplicate phi instructions to avoid
generating extra phi that we delete later.

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

4 years ago[Diagnostics] Make behaviour of Clang's -Wdeprecated-copy same as in GCC
Dávid Bolvanský [Sat, 23 Nov 2019 22:57:17 +0000 (23:57 +0100)]
[Diagnostics] Make behaviour of Clang's -Wdeprecated-copy same as in GCC

Do not warn for  functions that are explicitly marked delete or default, which follows the behavior of the GCC warning.

4 years ago[pdbutil] Fixed -Wdeprecated-copy in DbiModuleDescriptor
Dávid Bolvanský [Sat, 23 Nov 2019 22:33:22 +0000 (23:33 +0100)]
[pdbutil] Fixed -Wdeprecated-copy in DbiModuleDescriptor

4 years agoReland 'Fixed -Wdeprecated-copy warnings. NFCI.'
Dávid Bolvanský [Sat, 23 Nov 2019 22:08:22 +0000 (23:08 +0100)]
Reland 'Fixed -Wdeprecated-copy warnings. NFCI.'

Fixed hashtable copy ctor.

4 years ago[lldb][NFC] Do an early exit in LookupLocalVarNamespace and LookUpLldbObjCClass
Raphael Isemann [Sat, 23 Nov 2019 20:09:41 +0000 (21:09 +0100)]
[lldb][NFC] Do an early exit in LookupLocalVarNamespace and LookUpLldbObjCClass

4 years agogn build: set HAVE_VCS_VERSION_INC while building Version.cpp
Nico Weber [Sat, 23 Nov 2019 13:19:51 +0000 (08:19 -0500)]
gn build: set HAVE_VCS_VERSION_INC while building Version.cpp

And belatedly merge r353268 / r353269.

test/Driver/wasm-toolchain-lto.c currently requires getLLVMRevision()
to return something non-empty to pass. That's hopefully temporary,
but making Version.cpp work is probalby a good idea regardless.
(Note its contents will by default usually be out-of-date, because
llvm_allow_tardy_revision defaults to false.)

4 years ago[ELF][test] Clean up some thunk tests
Fangrui Song [Sat, 23 Nov 2019 19:14:45 +0000 (11:14 -0800)]
[ELF][test] Clean up some thunk tests

Use llvm-objdump --no-show-raw-insn --print-imm-hex
Prefer generic aarch64 triple to linux/freebsd specific triples.

4 years agoRevert 'Fixed -Wdeprecated-copy warnings. NFCI.'
Dávid Bolvanský [Sat, 23 Nov 2019 20:31:17 +0000 (21:31 +0100)]
Revert 'Fixed -Wdeprecated-copy warnings. NFCI.'

 pdbutil's test is failing.

4 years agoFixed typo introduced before commiting previous patch. NFCI.
Dávid Bolvanský [Sat, 23 Nov 2019 20:11:13 +0000 (21:11 +0100)]
Fixed typo introduced before commiting previous patch. NFCI.

4 years agoFixed -Wdeprecated-copy warnings. NFCI.
Dávid Bolvanský [Sat, 23 Nov 2019 20:01:56 +0000 (21:01 +0100)]
Fixed -Wdeprecated-copy warnings. NFCI.

4 years ago[analyzer][docs] NFC: Extend documentation for MallocOverflow checker
Borsik Gabor [Sat, 23 Nov 2019 19:55:19 +0000 (20:55 +0100)]
[analyzer][docs] NFC: Extend documentation for MallocOverflow checker

Patch by Benics Balázs

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

4 years ago[lldb][NFC] NFC refactoring for ClangExpressionDeclMap::LookupInModulesDeclVendor
Raphael Isemann [Sat, 23 Nov 2019 19:06:50 +0000 (20:06 +0100)]
[lldb][NFC] NFC refactoring for ClangExpressionDeclMap::LookupInModulesDeclVendor

Early exiting and deduplicating copy-pasted code.

4 years ago[analyzer] Add custom filter functions for GenericTaintChecker
Borsik Gabor [Sun, 8 Sep 2019 21:06:37 +0000 (23:06 +0200)]
[analyzer] Add custom filter functions for GenericTaintChecker

This patch is the last of the series of patches which allow the user to
annotate their functions with taint propagation rules.

I implemented the use of the configured filtering functions. These
functions can remove taintedness from the symbols which are passed at
the specified arguments to the filters.

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

4 years ago[FileCheck] Fixed -Wdeprecated-copy warning. NFCI.
Dávid Bolvanský [Sat, 23 Nov 2019 18:28:28 +0000 (19:28 +0100)]
[FileCheck] Fixed -Wdeprecated-copy warning. NFCI.

4 years agoRevert "[InlineCost] Fix infinite loop in indirect call evaluation"
Ehud Katz [Sat, 23 Nov 2019 18:15:34 +0000 (20:15 +0200)]
Revert "[InlineCost] Fix infinite loop in indirect call evaluation"

This reverts commit 854e956219e78cb8d7ef3b021d7be6b5d6b6af04.
It broke tests:
Transforms/Inline/redundant-loads.ll
Transforms/SampleProfile/inline-callee-update.ll

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

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

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

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

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

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

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

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

Reviewers: rampitec, arsenm

Reviewed By: rampitec

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

Tags: #llvm

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

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

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

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

Fixes PR35469.

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

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

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

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

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

Reviewers: jrtc27, nemanjai, glaubitz

Reviewed By: nemanjai

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

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

The original commit message follows.

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

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

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

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

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

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

Fixes: e0f22fe04a5c9eb244ff0533549743b7deb03b99

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

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

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

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

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

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

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

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

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

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

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

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

https://reviews.llvm.org/D69462

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

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

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

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

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

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

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

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

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

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

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

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

https://reviews.llvm.org/D70583

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

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

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

This should have no functionality change.

https://reviews.llvm.org/D70556

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

Because b5913e6d2f landed again as c54959c0.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

To use this, you have to:

1. Import the script into lldb.

(lldb) command script import in_call_stack.py

2. Set a breakpoint and use the in_call_stack alias.

(lldb) b foo
(lldb) in_call_stack bar

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

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

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

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

https://reviews.llvm.org/D70416

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

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

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

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

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

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