platform/upstream/llvm.git
6 years ago[OpenCL] Disallow negative attribute arguments
Andrew Savonichev [Thu, 6 Sep 2018 11:54:09 +0000 (11:54 +0000)]
[OpenCL] Disallow negative attribute arguments

Summary:
Negative arguments in kernel attributes are silently bitcast'ed to
unsigned, for example:

    __attribute__((reqd_work_group_size(1, -1, 1)))
    __kernel void k() {}

is a complete equivalent of:

    __attribute__((reqd_work_group_size(1, 4294967294, 1)))
    __kernel void k() {}

This is likely an error, so the patch forbids negative arguments in
several OpenCL attributes. Users who really want 4294967294 can still
use it as an unsigned representation.

Reviewers: Anastasia, yaxunl, bader

Reviewed By: Anastasia, yaxunl, bader

Subscribers: bader, cfe-commits

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

llvm-svn: 341539

6 years ago[clangd] Fix data race in async fuzzyFind tests.
Ilya Biryukov [Thu, 6 Sep 2018 11:04:56 +0000 (11:04 +0000)]
[clangd] Fix data race in async fuzzyFind tests.

llvm-svn: 341538

6 years ago[LoopInterchange] Cleanup unused variables.
Florian Hahn [Thu, 6 Sep 2018 10:41:01 +0000 (10:41 +0000)]
[LoopInterchange] Cleanup unused variables.

llvm-svn: 341537

6 years agoFix argument type in MachineInstr::hasPropertyInBundle
Sven van Haastregt [Thu, 6 Sep 2018 10:25:59 +0000 (10:25 +0000)]
Fix argument type in MachineInstr::hasPropertyInBundle

The MCID::Flag enumeration now has more than 32 items, this means that
the hasPropertyBundle argument 'Mask' can overflow.

This patch changes the argument to be 64 bits instead.

Patch by Mikael Nilsson.

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

llvm-svn: 341536

6 years agoReland [ClangUserExpression][NFC] Removed unused code
Raphael Isemann [Thu, 6 Sep 2018 10:24:11 +0000 (10:24 +0000)]
Reland [ClangUserExpression][NFC] Removed unused code

The GetLanguageForExpr has side effects, so we can't remove this
call without breaking the completion mechanism. However, we can
keep the change that gets rid of this unnecessary variable.

llvm-svn: 341535

6 years ago[clangd] Set SymbolID for sema macros so that they can be merged with index macros.
Eric Liu [Thu, 6 Sep 2018 09:59:37 +0000 (09:59 +0000)]
[clangd] Set SymbolID for sema macros so that they can be merged with index macros.

Reviewers: sammccall

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

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

llvm-svn: 341534

6 years ago[LoopInterchange] Move preheader creation to transform stage and simplify.
Florian Hahn [Thu, 6 Sep 2018 09:57:27 +0000 (09:57 +0000)]
[LoopInterchange] Move preheader creation to transform stage and simplify.

There is no need to create preheaders in the analysis stage, we only
need them when adjusting the branches. Also, the only cases we need to
create our own preheaders is when they have more than 1 predecessors or
PHI nodes (even with only 1 predecessor, we could have an LCSSA phi
node). I have simplified the conditions and added some assertions to be
sure. Because we know the inner and outer loop need to be tightly
nested, it is sufficient to check if the inner loop preheader is the
outer loop header to check if we need to create a new preheader.

Reviewers: efriedma, mcrosier, karthikthecool

Reviewed By: efriedma

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

llvm-svn: 341533

6 years agoRevert "[ClangUserExpression][NFC] Removed unused code"
Raphael Isemann [Thu, 6 Sep 2018 09:42:44 +0000 (09:42 +0000)]
Revert "[ClangUserExpression][NFC] Removed unused code"

GetLanguageForExpr has side effects, so this actually breaks
the completion. Should fix TestExprCompletion.

llvm-svn: 341532

6 years ago[NFC] Simplify inner structure of InstructionPrecedenceTracking
Max Kazantsev [Thu, 6 Sep 2018 09:29:42 +0000 (09:29 +0000)]
[NFC] Simplify inner structure of InstructionPrecedenceTracking

Currently it has a set KnownBlocks that marks blocks as having cached
answers and a map FirstSpecialInsts that maps these blocks to first
special instructions in them. The value in the map is always non-null,
and for blocks that are known to have no special instructions the map
does not have an instance.

This patch removes KnownBlocks as obsolete. Instead, for blocks that
are known to have no special instructions, we just put a nullptr value.
This makes the code much easier to read.

llvm-svn: 341531

6 years ago[MSan] store origins for variadic function parameters in __msan_va_arg_origin_tls
Alexander Potapenko [Thu, 6 Sep 2018 08:50:11 +0000 (08:50 +0000)]
[MSan] store origins for variadic function parameters in __msan_va_arg_origin_tls

Add the __msan_va_arg_origin_tls TLS array to keep the origins for
variadic function parameters.
Change the instrumentation pass to store parameter origins in this array.

llvm-svn: 341528

6 years ago[SLC] Add an alignment to CreateGlobalString
David Green [Thu, 6 Sep 2018 08:42:17 +0000 (08:42 +0000)]
[SLC] Add an alignment to CreateGlobalString

Previously the alignment on the newly created global strings was not set,
meaning that DataLayout::getPreferredAlignment was free to overalign it
to 16 bytes. This caused unnecessary code bloat with the padding between
variables.

The main example of this happening was the printf->puts optimisation in
SimplifyLibCalls, but as the change here is made in
IRBuilderBase::CreateGlobalString, other globals using this will now be
aligned too.

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

llvm-svn: 341527

6 years agoReturn "[NFC] Add severe validation of InstructionPrecedenceTracking"
Max Kazantsev [Thu, 6 Sep 2018 08:33:02 +0000 (08:33 +0000)]
Return "[NFC] Add severe validation of InstructionPrecedenceTracking"

This validation patch has been reverted as rL341147 because of conserns raised by
@reames. This revision returns it as is to raise a discussion and address the concerns.

Differential Revision: https://reviews.llvm.org/D51523
Reviewed By: reames

llvm-svn: 341526

6 years ago[MSan] Make sure variadic function arguments do not overflow __msan_va_arg_tls
Alexander Potapenko [Thu, 6 Sep 2018 08:21:54 +0000 (08:21 +0000)]
[MSan] Make sure variadic function arguments do not overflow __msan_va_arg_tls

Turns out that calling a variadic function with too many (e.g. >100 i64's)
arguments overflows __msan_va_arg_tls, which leads to smashing other TLS
data with function argument shadow values.

getShadow() already checks for kParamTLSSize and returns clean shadow if
the argument does not fit, so just skip storing argument shadow for such
arguments.

llvm-svn: 341525

6 years ago[DebugInfo] Generate debug information for labels. (Fix PR37395)
Hsiangkai Wang [Thu, 6 Sep 2018 06:03:36 +0000 (06:03 +0000)]
[DebugInfo] Generate debug information for labels. (Fix PR37395)

Generate DILabel metadata and call llvm.dbg.label after label
statement to associate the metadata with the label.

After fixing PR37395.
After fixing problems in LiveDebugVariables.

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

llvm-svn: 341519

6 years ago[XRay] Add a BlockIndexer visitor for FDR Records.
Dean Michael Berris [Thu, 6 Sep 2018 05:55:57 +0000 (05:55 +0000)]
[XRay] Add a BlockIndexer visitor for FDR Records.

Summary:
This change adds a `BlockIndexer` type which maintains pointers to
records that belong to the same process+thread pairs. The indexing
happens with order of appearance of records as they are visited.

This version of the indexer currently only supports FDR version 3 logs,
which contain `BufferExtent` records. We will add support for v2 and v1
logs in follow-up patches.

This is another part of D50441.

Reviewers: eizan, kpw, mboerger

Reviewed By: mboerger

Subscribers: mboerger, mgorny, hiraditya, llvm-commits

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

llvm-svn: 341518

6 years agoRevert "[IndVars] Turn isValidRewrite into an assertion" because it seems wrong
Max Kazantsev [Thu, 6 Sep 2018 05:52:47 +0000 (05:52 +0000)]
Revert "[IndVars] Turn isValidRewrite into an assertion" because it seems wrong

llvm-svn: 341517

6 years ago[IndVars] Turn isValidRewrite into an assertion
Max Kazantsev [Thu, 6 Sep 2018 05:21:25 +0000 (05:21 +0000)]
[IndVars] Turn isValidRewrite into an assertion

Function rewriteLoopExitValues contains a check on isValidRewrite which
is needed to make sure that SCEV does not convert the pattern
`gep Base, (&p[n] - &p[0])` into `gep &p[n], Base - &p[0]`. This problem
has been fixed in SCEV long ago, so this check is just obsolete.

This patch converts it into an assertion to make sure that the SCEV will
not mess up this case in the future.

Differential Revision: https://reviews.llvm.org/D51582
Reviewed By: atrick

llvm-svn: 341516

6 years agoRevert rL341509 to fix massive failures on buildbots
Max Kazantsev [Thu, 6 Sep 2018 04:40:49 +0000 (04:40 +0000)]
Revert rL341509 to fix massive failures on buildbots

llvm-svn: 341515

6 years ago[libfuzzer] Temporarily disable unittests failing on Windows.
Max Moroz [Thu, 6 Sep 2018 02:54:47 +0000 (02:54 +0000)]
[libfuzzer] Temporarily disable unittests failing on Windows.

Summary:
Patch by Jonathan Metzman (@metzman).

Reviewers: morehouse, Dor1s

Reviewed By: Dor1s

Subscribers: kcc, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 341514

6 years ago[DebugInfo] Do not generate label debug info if it has been processed.
Hsiangkai Wang [Thu, 6 Sep 2018 02:22:06 +0000 (02:22 +0000)]
[DebugInfo] Do not generate label debug info if it has been processed.

In DwarfDebug::collectEntityInfo(), if the label entity is processed in
DbgLabels list, it means the label is not optimized out. There is no
need to generate debug info for it with null position.

llvm-svn: 341513

6 years ago[X86][Assembler] Allow %eip as a register in 32-bit mode for .cfi directives.
Craig Topper [Thu, 6 Sep 2018 02:03:14 +0000 (02:03 +0000)]
[X86][Assembler] Allow %eip as a register in 32-bit mode for .cfi directives.

This basically reverts a change made in r336217, but improves the text of the error message for not allowing IP-relative addressing in 32-bit mode.

Fixes PR38826.

Patch by Iain Sandoe.

llvm-svn: 341512

6 years agoRe-instate a bit of code that was commented out in r188246 which
Jason Molenda [Thu, 6 Sep 2018 00:55:27 +0000 (00:55 +0000)]
Re-instate a bit of code that was commented out in r188246 which
reads an ObjectFileMachO's string table in one chunk.  Originally
this was commented out because binaries in the system's shared cache
all share a mega-string table and so reading the entire mega-strtab
for each binary was a performance problem.

In the reinstated code, I add a check that the binary we're reading
from memory is not in the shared cache (there isn't a constant in
<mach-o/loader.h> for this bit yet; we hardcode the value in one
other place in ObjectFileMachO alread).  For binaries that we're
reading out of memory that are NOT in the shared cache, reading
the string table in one chunk is a big performance improvement.

Also have debugserver send up the flags value for binaries in its
response to the jGetLoadedDynamicLibrariesInfos request.

NFC.

<rdar://problem/33604496>

llvm-svn: 341511

6 years ago[llvm-dwp] Fix `UN:` lines (supposed to be `RUN:`) in X86/simple.test and adjust...
Fangrui Song [Thu, 6 Sep 2018 00:46:30 +0000 (00:46 +0000)]
[llvm-dwp] Fix `UN:` lines (supposed to be `RUN:`) in X86/simple.test and adjust check lines for TYPES:

Reviewers: dblaikie, aprantl

Subscribers: llvm-commits

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

llvm-svn: 341510

6 years ago[llvm-dwp] Use buffer_stream if output file is not seekable (e.g. "-")
Fangrui Song [Thu, 6 Sep 2018 00:06:25 +0000 (00:06 +0000)]
[llvm-dwp] Use buffer_stream if output file is not seekable (e.g. "-")

Reviewers: dblaikie, pcc

Subscribers: llvm-commits

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

llvm-svn: 341509

6 years agoFix some warnings.
Zachary Turner [Thu, 6 Sep 2018 00:06:20 +0000 (00:06 +0000)]
Fix some warnings.

llvm-svn: 341508

6 years ago[hwasan] when verbose_threads==1, print the memory usage per thread
Kostya Serebryany [Wed, 5 Sep 2018 23:52:31 +0000 (23:52 +0000)]
[hwasan] when verbose_threads==1, print the memory usage per thread

llvm-svn: 341507

6 years agoPrint column info in backtraces et al. if available
Adrian Prantl [Wed, 5 Sep 2018 23:52:08 +0000 (23:52 +0000)]
Print column info in backtraces et al. if available

This patch allows LLDB to print column info in backtraces et al. if
available, which is useful when the backtrace contains a frame like
the following:

  f(can_crash(0), can_crash(1));

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

llvm-svn: 341506

6 years agoFix silly error in unittest helper.
Zachary Turner [Wed, 5 Sep 2018 23:45:48 +0000 (23:45 +0000)]
Fix silly error in unittest helper.

llvm-svn: 341505

6 years agoNFC: improve ARM64 isFPImmLegal debug print
JF Bastien [Wed, 5 Sep 2018 23:38:11 +0000 (23:38 +0000)]
NFC: improve ARM64 isFPImmLegal debug print

Forking this change from D51706. This just made it easier to understand llc
output with -debug.

llvm-svn: 341504

6 years ago[PDB] Refactor the PDB symbol classes to fix a reuse bug.
Zachary Turner [Wed, 5 Sep 2018 23:30:38 +0000 (23:30 +0000)]
[PDB] Refactor the PDB symbol classes to fix a reuse bug.

The way DIA SDK works is that when you request a symbol, it
gets assigned an internal identifier that is unique for the
life of the session.  You can then use this identifier to
get back the same symbol, with all of the same internal state
that it had before, even if you "destroyed" the original
copy of the object you had.

This didn't work properly in our native implementation, and
if you destroyed an object for a particular symbol, then
requested the same symbol again, it would get assigned a new
ID and you'd get a fresh copy of the object.  In order to fix
this some refactoring had to happen to properly reuse cached
objects.  Some unittests are added to verify that symbol
reuse is taking place, making use of the new unittest input
feature.

llvm-svn: 341503

6 years agoAdd support for unittest inputs.
Zachary Turner [Wed, 5 Sep 2018 23:30:17 +0000 (23:30 +0000)]
Add support for unittest inputs.

Occasionally it is useful to have unittest which take inputs.
While we normally try to have this test be more of a lit test
we occasionally don't have tools that can exercise the code
in the right way to test certain things.  LLDB has been using
this style of unit test for a while, particularly with regards
to how it tests core dump and minidump file parsing.  Recently
i needed this as well for the case where we want to test that
some of the PDB reading code works correctly.  It needs to
exercise the code in a way that is not covered by any dumper
and would be impractical to implement in one of the dumpers,
but requires a valid PDB file.  Since this is now needed by
more than one project, it makes sense to have this be a
generally supported thing that unit tests can do, and we just
encourage people to use this sparingly.

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

llvm-svn: 341502

6 years ago[hwasan] simplify the code, NFC
Kostya Serebryany [Wed, 5 Sep 2018 23:22:38 +0000 (23:22 +0000)]
[hwasan] simplify the code, NFC

llvm-svn: 341501

6 years ago[hwasan] Don't handle signals on Android.
Evgeniy Stepanov [Wed, 5 Sep 2018 22:46:19 +0000 (22:46 +0000)]
[hwasan] Don't handle signals on Android.

Sigtrap is used for error reporting, but all other signals are better
left for the platform.

In particular, sanitizer signal handlers do not dump registers or
memory which makes debugging harder for no good reason.

llvm-svn: 341500

6 years agoPR38627: Fix handling of exception specification adjustment for
Richard Smith [Wed, 5 Sep 2018 22:30:37 +0000 (22:30 +0000)]
PR38627: Fix handling of exception specification adjustment for
destructors.

We previously tried to patch up the exception specification after
completing the class, which went wrong when the exception specification
was needed within the class body (in particular, by a friend
redeclaration of the destructor in a nested class). We now mark the
destructor as having a not-yet-computed exception specification
immediately after creating it.

This requires delaying various checks against the exception
specification (where we'd previously have just got the wrong exception
specification, and now find we have an exception specification that we
can't compute yet) when those checks fire while the class is being
defined.

This also exposed an issue that we were missing a CodeSynthesisContext
for computation of exception specifications (otherwise we'd fail to make
the module containing the definition of the class visible when computing
its members' exception specs). Adding that incidentally also gives us a
diagnostic quality improvement.

This has also exposed an pre-existing problem: making the exception
specification evaluation context a non-SFINAE context (as it should be)
results in a bootstrap failure; PR38850 filed for this.

llvm-svn: 341499

6 years agoRemove unnecessary options from test RUN lines.
Richard Trieu [Wed, 5 Sep 2018 22:14:46 +0000 (22:14 +0000)]
Remove unnecessary options from test RUN lines.

These tests do not check the color printing, so color options should not
be used when running them.

llvm-svn: 341498

6 years agoSet Windows console mode to enable support for ansi escape codes
David Bolvansky [Wed, 5 Sep 2018 22:06:58 +0000 (22:06 +0000)]
Set Windows console mode to enable support for ansi escape codes

Summary:
Windows console now supports supports ANSI escape codes, but we need to enable it using SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.

https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences.

Syntax hightlighting now works fine on Windows:
https://i.imgur.com/P0i04A7.png

Reviewers: JDevlieghere, teemperor, zturner

Reviewed By: zturner

Subscribers: abidh, lldb-commits

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

llvm-svn: 341497

6 years agoAdd triple to test case.
Richard Trieu [Wed, 5 Sep 2018 21:55:09 +0000 (21:55 +0000)]
Add triple to test case.

This test uses enums, which have different behavior when targeting different
systems.  Specifying a triple will give predictable behavior to this test.

llvm-svn: 341496

6 years ago[libfuzzer] Replace memmem with strstr.
Matt Morehouse [Wed, 5 Sep 2018 21:03:43 +0000 (21:03 +0000)]
[libfuzzer] Replace memmem with strstr.

Summary: Memmem is not available on Windows.

Patch By: metzman

Reviewers: morehouse

Reviewed By: morehouse

Subscribers: george.karpenkov, morehouse

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

llvm-svn: 341495

6 years agoRemove some unnecessary constructor arguments.
Lang Hames [Wed, 5 Sep 2018 20:57:41 +0000 (20:57 +0000)]
Remove some unnecessary constructor arguments.

ExecutionSession defaults to creating a new shared pool if none is provided,
so explicitly passing one in is unnecessary.

llvm-svn: 341494

6 years agoNFC: more memset inline arm64 coverage
JF Bastien [Wed, 5 Sep 2018 20:35:06 +0000 (20:35 +0000)]
NFC: more memset inline arm64 coverage

I'm looking at some codegen optimization in this area and want to make sure I understand the current codegen and don't regress it. This patch further expands the tests (which I already expanded in r341406) to capture more of the current code generation when it comes to stack-based small non-zero memset on arm64. This patch annotates some potential fixes.

llvm-svn: 341493

6 years agoRevert "Enable DWARF accelerator tables by default when tuning for lldb (-glldb ...
Pavel Labath [Wed, 5 Sep 2018 20:20:28 +0000 (20:20 +0000)]
Revert "Enable DWARF accelerator tables by default when tuning for lldb (-glldb => -gpubnames)"

This reverts commit r341472 due to breakage in green dragon bots.

llvm-svn: 341492

6 years agoForbid address spaces on compound literals in local scope.
John McCall [Wed, 5 Sep 2018 19:22:40 +0000 (19:22 +0000)]
Forbid address spaces on compound literals in local scope.

Patch by Bevin Hansson!

llvm-svn: 341491

6 years ago[Sema] Don't warn about omitting unavailable enum constants in a switch
Erik Pilkington [Wed, 5 Sep 2018 19:13:27 +0000 (19:13 +0000)]
[Sema] Don't warn about omitting unavailable enum constants in a switch

rdar://42717026

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

llvm-svn: 341490

6 years agoAdd -Wobjc-property-assign-on-object-type.
John McCall [Wed, 5 Sep 2018 19:02:00 +0000 (19:02 +0000)]
Add -Wobjc-property-assign-on-object-type.

This is a warning about using 'assign' instead of 'unsafe_unretained'
in Objective-C property declarations.  It's off by default because there
isn't consensus in the Objective-C steering group that this is the right
thing to do, but we're nonetheless okay with adding it because there's a
substantial pool of Objective-C programmers who will appreciate the warning.

Patch by Alfred Zien!

llvm-svn: 341489

6 years ago[clang-tidy] minor bug fix to AbseilMatcher.h
Eric Liu [Wed, 5 Sep 2018 19:01:34 +0000 (19:01 +0000)]
[clang-tidy] minor bug fix to AbseilMatcher.h

This missing directory is not yet released, but is causing some problems
internally. It's gonna be released eventually and received permission to
include it here. This matcher will also be periodically updated by my
team as we have more releases and or problems internally.

Patch by Hugo Gonzalez!

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

llvm-svn: 341488

6 years agoModernize NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode
Pavel Labath [Wed, 5 Sep 2018 18:08:56 +0000 (18:08 +0000)]
Modernize NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode

return the opcode as a Expected<ArrayRef> instead of a
Status+pointer+size combo.

I also move the linux implementation to the base class, as the trap
opcodes are likely to be the same for all/most implementations of the
class (except the arm one, where linux chooses a different opcode than
what the arm spec recommends, which I keep linux-specific).

llvm-svn: 341487

6 years agolld-link: Write an empty "repro" debug directory entry if /Brepro is passed
Nico Weber [Wed, 5 Sep 2018 18:02:43 +0000 (18:02 +0000)]
lld-link: Write an empty "repro" debug directory entry if /Brepro is passed

If the coff timestamp is set to a hash, like lld-link does if /Brepro is
passed, the coff spec suggests that a IMAGE_DEBUG_TYPE_REPRO entry is in the
debug directory. This lets lld-link write such a section.
Fixes PR38429, see bug for details.

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

llvm-svn: 341486

6 years agoHandle zero-length debug directory entries.
Nico Weber [Wed, 5 Sep 2018 18:01:04 +0000 (18:01 +0000)]
Handle zero-length debug directory entries.

Part of https://reviews.llvm.org/D51652 (tests will be in the lld repo)

llvm-svn: 341485

6 years agoTest Commit for git-svn-cleanup comment.
Erich Keane [Wed, 5 Sep 2018 17:14:21 +0000 (17:14 +0000)]
Test Commit for git-svn-cleanup comment.

Removes the class name for the Expr class, which isn't necessary.

llvm-svn: 341484

6 years ago[OPENMP][NVPTX] Disable runtime-type info for CUDA devices.
Alexey Bataev [Wed, 5 Sep 2018 17:10:30 +0000 (17:10 +0000)]
[OPENMP][NVPTX] Disable runtime-type info for CUDA devices.

RTTI is not supported by the NVPTX target.

llvm-svn: 341483

6 years agoHold GIL while allocating memory for PythonString.
Tatyana Krasnukha [Wed, 5 Sep 2018 17:07:29 +0000 (17:07 +0000)]
Hold GIL while allocating memory for PythonString.

Summary:
Swig wraps C++ code into SWIG_PYTHON_THREAD_BEGIN_ALLOW; ...  SWIG_PYTHON_THREAD_END_ALLOW;
Thus, LLDB crashes with "Fatal Python error: Python memory allocator called without holding the GIL" when calls an lldb_SB***___str__ function.

Reviewers: clayborg

Reviewed By: clayborg

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

llvm-svn: 341482

6 years ago[DAGCombiner] try to convert pow(x, 0.25) to sqrt(sqrt(x))
Sanjay Patel [Wed, 5 Sep 2018 17:01:56 +0000 (17:01 +0000)]
[DAGCombiner] try to convert pow(x, 0.25) to sqrt(sqrt(x))

This was proposed as an IR transform in D49306, but it was not clearly justifiable as a canonicalization.
Here, we only do the transform when the target tells us that sqrt can be lowered with inline code.

This is the basic case. Some potential enhancements are in the TODO comments:

1. Generalize the transform for other exponents (allow more than 2 sqrt calcs if that's really cheaper).
2. If we have less fast-math-flags, generate code to avoid -0.0 and/or INF.
3. Allow the transform when optimizing/minimizing size (might require a target hook to get that right).

Note that by default, x86 converts single-precision sqrt calcs into sqrt reciprocal estimate with
refinement. That codegen is controlled by CPU attributes and can be manually overridden. We have plenty
of test coverage for that already, so I didn't bother to include extra testing for that here. AArch uses
its full-precision ops in all cases (not sure if that's the intended behavior or not, but that should
also be covered by existing tests).

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

llvm-svn: 341481

6 years ago[hwasan] deflake a test
Kostya Serebryany [Wed, 5 Sep 2018 16:09:53 +0000 (16:09 +0000)]
[hwasan] deflake a test

llvm-svn: 341480

6 years ago[XRay] Use a function to return a constant
Dean Michael Berris [Wed, 5 Sep 2018 16:03:21 +0000 (16:03 +0000)]
[XRay] Use a function to return a constant

We do this instead of using static constexpr char arrays because MSVC
2015 cannot handle the constant initialisation of those along with the
out-of-line storage declaration.

This is a follow-up to D51672.

llvm-svn: 341479

6 years ago[Hexagon] Ignore unnamed globals in HexagonConstExtenders
Krzysztof Parzyszek [Wed, 5 Sep 2018 15:54:44 +0000 (15:54 +0000)]
[Hexagon] Ignore unnamed globals in HexagonConstExtenders

This replaces r337723. The global list in the module can be huge with LTO,
plus the module can change between different invocations of the pass, so
there is no easy way to deterministically cache the ordering (especially
in the presence of multiple threads).

llvm-svn: 341478

6 years ago[XRay] Use `const` instead of `constexpr` in storage declaration
Dean Michael Berris [Wed, 5 Sep 2018 15:19:43 +0000 (15:19 +0000)]
[XRay] Use `const` instead of `constexpr` in storage declaration

This should make MSVC happy with the storage provided for static
constexpr character arrays out-of-line.

Follow-up to D51672.

llvm-svn: 341477

6 years ago[Sema] Store MacroInfo in CodeCompletionResult for macro results.
Eric Liu [Wed, 5 Sep 2018 14:59:17 +0000 (14:59 +0000)]
[Sema] Store MacroInfo in CodeCompletionResult for macro results.

Summary:
This provides information about the macro definition. For example, it
can be used to compute macro USRs.

Reviewers: sammccall

Subscribers: cfe-commits

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

llvm-svn: 341476

6 years agoFix arm_neon.h and arm_fp16.h generation for compiling with std=c89
Diogo N. Sampaio [Wed, 5 Sep 2018 14:56:21 +0000 (14:56 +0000)]
Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89

Summary:
The inline attribute is not valid for C standard 89. Replace the argument in the generation of header files with __inline, as well adding tests for both header files.

Reviewers: pbarrio, SjoerdMeijer, javed.absar, t.p.northover

Subscribers: t.p.northover, kristof.beyls, chrib, cfe-commits

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

test/Headers/arm-fp16-header.c
test/Headers/arm-neon-header.c
utils/TableGen/NeonEmitter.cpp

llvm-svn: 341475

6 years agoEnable symbolize-deadlock.test on Windows
Max Moroz [Wed, 5 Sep 2018 14:43:38 +0000 (14:43 +0000)]
Enable symbolize-deadlock.test on Windows

Summary:
Remove unneeded #include of <unistd.h> from SymbolizeDeadlock.cpp to
enable compilation on Windows and enable symbolize-deadlock.test on
Windows.

Patch by Jonathan Metzman (@metzman).

Reviewers: Dor1s

Reviewed By: Dor1s

Subscribers: kcc, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 341473

6 years agoEnable DWARF accelerator tables by default when tuning for lldb (-glldb => -gpubnames)
Pavel Labath [Wed, 5 Sep 2018 14:38:44 +0000 (14:38 +0000)]
Enable DWARF accelerator tables by default when tuning for lldb (-glldb => -gpubnames)

Summary:
DWARF v5 accelerator tables provide a considerable performance
improvement for lldb and will make the default -glldb behavior same on
all targets (right now we emit apple tables on apple targets, but these
are not controlled by -gpubnames, only by -glldb).

Reviewers: dblaikie

Subscribers: probinson, clayborg, JDevlieghere, aprantl, cfe-commits

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

llvm-svn: 341472

6 years ago[www] Updated outdated download links [NFC]
Raphael Isemann [Wed, 5 Sep 2018 14:27:48 +0000 (14:27 +0000)]
[www] Updated outdated download links [NFC]

Also added ubuntu and Arch Linux links.

llvm-svn: 341471

6 years ago[benchmark] Fix 32-bit build failure
Kirill Bobyrev [Wed, 5 Sep 2018 14:15:39 +0000 (14:15 +0000)]
[benchmark] Fix 32-bit build failure

This patch applies upstream commit:
https://github.com/google/benchmark/commit/f0901417c89d123474e6b91365029cfe32cf89dc

Tim Northover pointed out that benchmark build might be broken on 32-bit
macOS. This commit by Roman Lebedev (lebedev.ri) resolves the issue.

Reviewed By: lebedev.ri

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

llvm-svn: 341469

6 years ago[ControlHeightReduction] Remove unused includes
Benjamin Kramer [Wed, 5 Sep 2018 13:51:05 +0000 (13:51 +0000)]
[ControlHeightReduction] Remove unused includes

Also clang-format them.

llvm-svn: 341468

6 years ago[clangd] Fix type/variable name conflict on some compilers
Sam McCall [Wed, 5 Sep 2018 13:22:11 +0000 (13:22 +0000)]
[clangd] Fix type/variable name conflict on some compilers

llvm-svn: 341467

6 years ago[clangd] Fix references.test assertions
Sam McCall [Wed, 5 Sep 2018 13:17:51 +0000 (13:17 +0000)]
[clangd] Fix references.test assertions

llvm-svn: 341466

6 years ago[clangd] make zlib compression optional for binary format
Sam McCall [Wed, 5 Sep 2018 13:17:47 +0000 (13:17 +0000)]
[clangd] make zlib compression optional for binary format

llvm-svn: 341465

6 years ago[llvm-strip] Support stripping multiple input files
Jordan Rupprecht [Wed, 5 Sep 2018 13:10:03 +0000 (13:10 +0000)]
[llvm-strip] Support stripping multiple input files

Summary:
Allow strip to be called on multiple input files, which is interpreted as stripping N files in place. Using multiple input files is incompatible with -o.

To allow this, create a `DriverConfig` struct which just wraps a list of `CopyConfigs`. objcopy will only ever have a single `CopyConfig`, but strip will have N (where N >= 1) CopyConfigs.

Reviewers: alexshap, jakehehrlich

Reviewed By: alexshap, jakehehrlich

Subscribers: MaskRay, jakehehrlich, llvm-commits

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

llvm-svn: 341464

6 years ago[clangd] Sort GoToDefinition results.
Haojian Wu [Wed, 5 Sep 2018 12:00:15 +0000 (12:00 +0000)]
[clangd] Sort GoToDefinition results.

Summary:
GoToDefinition returns all declaration results (implicit/explicit) that are
in the same location, and the results are returned in arbitrary order.

Some LSP clients defaultly take the first result as the final result, which
might present a bad result (implicit decl) to users.

This patch ranks the result based on whether the declarations are
referenced explicitly/implicitly. We put explicit declarations first.

This also improves the "hover" (which just take the first result) feature
in some cases.

Reviewers: ilya-biryukov

Subscribers: kadircet, ioeric, MaskRay, jkorous, mgrang, arphaman, cfe-commits

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

llvm-svn: 341463

6 years ago[clangd] Add xrefs LSP boilerplate implementation.
Sam McCall [Wed, 5 Sep 2018 11:53:07 +0000 (11:53 +0000)]
[clangd] Add xrefs LSP boilerplate implementation.

Reviewers: ilya-biryukov, ioeric

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 341462

6 years ago[Aggressive InstCombine] Move C bindings to their own header file.
Benjamin Kramer [Wed, 5 Sep 2018 11:41:12 +0000 (11:41 +0000)]
[Aggressive InstCombine] Move C bindings to their own header file.

llvm-svn: 341461

6 years agoFix -Wdocumentation warning. NFCI.
Simon Pilgrim [Wed, 5 Sep 2018 10:44:03 +0000 (10:44 +0000)]
Fix -Wdocumentation warning. NFCI.

llvm-svn: 341460

6 years ago[clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use consistent style.
Sam McCall [Wed, 5 Sep 2018 10:39:58 +0000 (10:39 +0000)]
[clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use consistent style.

llvm-svn: 341459

6 years ago[clangd] Implement findReferences function
Sam McCall [Wed, 5 Sep 2018 10:33:36 +0000 (10:33 +0000)]
[clangd] Implement findReferences function

clangd will use findReferences to provide LSP's reference feature.

llvm-svn: 341458

6 years ago[DebugInfo] Normalize common kinds of DWARF sub-expressions.
Jonas Devlieghere [Wed, 5 Sep 2018 10:18:36 +0000 (10:18 +0000)]
[DebugInfo] Normalize common kinds of DWARF sub-expressions.

Normalize common kinds of DWARF sub-expressions to make debug info
encoding a bit more compact:

  DW_OP_constu [X < 32] -> DW_OP_litX
  DW_OP_constu [all ones] -> DW_OP_lit0, DW_OP_not (64-bit only)

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

llvm-svn: 341457

6 years ago[NFC] Add test on full IV widening
Max Kazantsev [Wed, 5 Sep 2018 10:10:59 +0000 (10:10 +0000)]
[NFC] Add test on full IV widening

llvm-svn: 341456

6 years ago[VFS] Cache the current working directory for the real FS.
Eric Liu [Wed, 5 Sep 2018 09:45:27 +0000 (09:45 +0000)]
[VFS] Cache the current working directory for the real FS.

Reviewers: sammccall

Subscribers: cfe-commits

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

llvm-svn: 341455

6 years agoRemove FrameAccess struct from hasLoadFromStackSlot
Sander de Smalen [Wed, 5 Sep 2018 08:59:50 +0000 (08:59 +0000)]
Remove FrameAccess struct from hasLoadFromStackSlot

This removes the FrameAccess struct that was added to the interface
in D51537, since the PseudoValue from the MachineMemoryOperand
can be safely casted to a FixedStackPseudoSourceValue.

Reviewers: MatzeB, thegameg, javed.absar

Reviewed By: thegameg

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

llvm-svn: 341454

6 years ago[clangd] Fix typo. NFC
Fangrui Song [Wed, 5 Sep 2018 08:01:37 +0000 (08:01 +0000)]
[clangd] Fix typo. NFC

llvm-svn: 341452

6 years ago[clangd] Fix buildbot failures on older compilers from r341375
Sam McCall [Wed, 5 Sep 2018 07:52:49 +0000 (07:52 +0000)]
[clangd] Fix buildbot failures on older compilers from r341375

llvm-svn: 341451

6 years agoclang-format: Fix formatting C++ namespaces with preceding 'inline' or 'export' specifier
Sam McCall [Wed, 5 Sep 2018 07:44:02 +0000 (07:44 +0000)]
clang-format: Fix formatting C++ namespaces with preceding 'inline' or 'export' specifier

This fixes formatting namespaces with preceding 'inline' and 'export' (Modules TS) specifiers.

This change fixes namespaces not being identified as such with preceding 'inline' or 'export' specifiers.

Motivation: I was experimenting with the Modules TS (-fmodules-ts) and found it would be useful if clang-format would correctly format 'export namespace'. While making the changes, I noticed that similar issues still exist with 'inline namespace', and addressed them as well.

Patch by Marco Elver!

Reviewers: klimek, djasper, owenpan, sammccall

Reviewed By: owenpan, sammccall

Subscribers: owenpan, cfe-commits

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

llvm-svn: 341450

6 years ago[clangd] Tune macro quality scoring for code completion.
Eric Liu [Wed, 5 Sep 2018 07:40:38 +0000 (07:40 +0000)]
[clangd] Tune macro quality scoring for code completion.

x0.2 seems to be too much penalty, macros might be wanted in some cases;
changing to 0.5x instead. The tuning didn't affect ranking for non-macro
completions.

llvm-svn: 341449

6 years ago[libomptaret][test] Announce compiler features
Jonas Hahnfeld [Wed, 5 Sep 2018 07:26:00 +0000 (07:26 +0000)]
[libomptaret][test] Announce compiler features

This is a follow-up to r341371: The new test for PR38704 doesn't
work with Clang 6.0. It uses an UNSUPPORTED: clang-6, but that
hasn't worked because the compiler features weren't known to lit.

llvm-svn: 341448

6 years ago[XRay] Add a RecordPrinter visitor for FDR Records
Dean Michael Berris [Wed, 5 Sep 2018 06:57:23 +0000 (06:57 +0000)]
[XRay] Add a RecordPrinter visitor for FDR Records

Summary:
This change adds a `RecordPrinter` type which does some basic text
serialization of the FDR record instances. This is one component of the
tool we're building to dump the records from an FDR mode log as-is.

This is a small part of D50441.

Reviewers: eizan, kpw

Subscribers: mgorny, hiraditya, llvm-commits

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

llvm-svn: 341447

6 years ago[DebugInfo] Fix bug in LiveDebugVariables.
Hsiangkai Wang [Wed, 5 Sep 2018 05:58:53 +0000 (05:58 +0000)]
[DebugInfo] Fix bug in LiveDebugVariables.

In lib/CodeGen/LiveDebugVariables.cpp, it uses std::prev(MBBI) to
get DebugValue's SlotIndex. However, the previous instruction may be
also a debug instruction. It could not use a debug instruction to query
SlotIndex in mi2iMap.

Scan all debug instructions and use the first debug instruction to query
SlotIndex for following debug instructions. Only handle DBG_VALUE in
handleDebugValue().

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

llvm-svn: 341446

6 years ago[Xray] Darwin providing defined value for weak symbols to fix linkage issue
David Carlier [Wed, 5 Sep 2018 05:18:34 +0000 (05:18 +0000)]
[Xray] Darwin providing defined value for weak symbols to fix linkage issue

- Temporary hack to make the buildbot failure stop on Darwin.

llvm-svn: 341445

6 years agoPrevent unsigned overflow.
Richard Trieu [Wed, 5 Sep 2018 04:19:15 +0000 (04:19 +0000)]
Prevent unsigned overflow.

The sum of the weights is caculated in an APInt, which has a width smaller than
64.  In certain cases, the sum of the widths would overflow when calculations
are done inside an APInt, but would not if done with uint64_t.  Since the
values will be passed as uint64_t in the function call anyways, do all the math
in 64 bits.  Also added an assert in case the probabilities overflow 64 bits.

llvm-svn: 341444

6 years agoFix -Wunused-function in release build after rL341386
Fangrui Song [Wed, 5 Sep 2018 03:10:20 +0000 (03:10 +0000)]
Fix -Wunused-function in release build after rL341386

llvm-svn: 341443

6 years agoAdd glibc_prereq to platform limits mmsghdr
Brian Cain [Wed, 5 Sep 2018 02:15:54 +0000 (02:15 +0000)]
Add glibc_prereq to platform limits mmsghdr

sendmmsg requires glibc >= 2.14.

Fixes PR38589.

Review: https://reviews.llvm.org/D51538
llvm-svn: 341442

6 years ago[hwasan] revert r341435 as it breaks the bot on aarch64
Kostya Serebryany [Wed, 5 Sep 2018 01:29:08 +0000 (01:29 +0000)]
[hwasan] revert r341435 as it breaks the bot on aarch64

llvm-svn: 341441

6 years ago[hwasan] fix colored output
Kostya Serebryany [Wed, 5 Sep 2018 01:27:48 +0000 (01:27 +0000)]
[hwasan] fix colored output

llvm-svn: 341440

6 years ago[WebAssembly] clang-format (NFC)
Heejin Ahn [Wed, 5 Sep 2018 01:27:38 +0000 (01:27 +0000)]
[WebAssembly] clang-format (NFC)

Summary: This patch runs clang-format on all wasm-only files.

Reviewers: aardappel, dschuff, sunfish, tlively

Subscribers: MatzeB, sbc100, jgravelle-google, llvm-commits

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

llvm-svn: 341439

6 years ago[hwasan] print thread IDs when reporting a bug (also had to fix pthread_create on...
Kostya Serebryany [Wed, 5 Sep 2018 01:16:50 +0000 (01:16 +0000)]
[hwasan] print thread IDs when reporting a bug (also had to fix pthread_create on Linux)

llvm-svn: 341438

6 years agoAllow all supportable non-type attributes to be used with #pragma clang attribute.
Richard Smith [Wed, 5 Sep 2018 00:28:57 +0000 (00:28 +0000)]
Allow all supportable non-type attributes to be used with #pragma clang attribute.

Summary:
We previously disallowed use of undocumented attributes with #pragma clang
attribute, but the justification for doing so was weak and it prevented many
reasonable use cases.

Reviewers: aaron.ballman, arphaman

Subscribers: cfe-commits, rnk, benlangmuir, dexonsmith, erik.pilkington

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

llvm-svn: 341437

6 years agoFix -Wunused-private-variable on non-Windows
Reid Kleckner [Wed, 5 Sep 2018 00:18:05 +0000 (00:18 +0000)]
Fix -Wunused-private-variable on non-Windows

I didn't want to use ifdefs in headers, but I'll do it to pacify a
warning.

llvm-svn: 341436

6 years ago[hwasan] use real TLS on linux to store the current thread -- this way we can call...
Kostya Serebryany [Wed, 5 Sep 2018 00:17:23 +0000 (00:17 +0000)]
[hwasan] use real TLS on linux to store the current thread -- this way we can call t->Destroy in __hwasan_thread_exit, same as on Android

llvm-svn: 341435

6 years ago[Windows] Convert from UTF-8 to UTF-16 when writing to a Windows console
Reid Kleckner [Wed, 5 Sep 2018 00:08:56 +0000 (00:08 +0000)]
[Windows] Convert from UTF-8 to UTF-16 when writing to a Windows console

Summary:
Calling WriteConsoleW is the most reliable way to print Unicode
characters to a Windows console.

If binary data gets printed to the console, attempting to re-encode it
shouldn't be a problem, since garbage in can produce garbage out.

This breaks printing strings in the local codepage, which WriteConsoleA
knows how to handle. For example, this can happen when user source code
is encoded with the local codepage, and an LLVM tool quotes it while
emitting a caret diagnostic. This is unfortunate, but well-behaved tools
should validate that their input is UTF-8 and escape non-UTF-8
characters before sending them to raw_fd_ostream. Clang already does
this, but not all LLVM tools do this.

One drawback to the current implementation is printing a string a byte
at a time doesn't work. Consider this LLVM code:
  for (char C : MyStr) outs() << C;

Because outs() is now unbuffered, we wil try to convert each byte to
UTF-16, which will fail. However, this already didn't work, so I think
we may as well update callers that do that as we find them to print
complete portions of strings. You can see a real example of this in my
patch to SourceMgr.cpp

Fixes PR38669 and PR36267.

Reviewers: zturner, efriedma

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 341433

6 years ago[hwasan] simplify the code, NFC
Kostya Serebryany [Wed, 5 Sep 2018 00:01:45 +0000 (00:01 +0000)]
[hwasan] simplify the code, NFC

llvm-svn: 341432

6 years ago[hwasan] remove stale Thread:: data members. While doing so noticed that GetThreadSta...
Kostya Serebryany [Tue, 4 Sep 2018 23:57:09 +0000 (23:57 +0000)]
[hwasan] remove stale Thread:: data members. While doing so noticed that GetThreadStackAndTls was always called with 'at_initialization=true', fixed that.

llvm-svn: 341431

6 years ago[hwasan] add a unique id to a thread and add debug prints for thread creation/destruction
Kostya Serebryany [Tue, 4 Sep 2018 23:26:08 +0000 (23:26 +0000)]
[hwasan] add a unique id to a thread and add debug prints for thread creation/destruction

llvm-svn: 341428

6 years ago[InstCombine] fix xor-or-xor fold to check uses and handle commutes
Sanjay Patel [Tue, 4 Sep 2018 23:22:13 +0000 (23:22 +0000)]
[InstCombine] fix xor-or-xor fold to check uses and handle commutes

I'm probably missing some way to use m_Deferred to remove the code
duplication, but that can be a follow-up.

The improvement in demand_shrink_nsw.ll is an example of missing
the fold because the pattern matching was deficient. I didn't try
to follow the bits in that test, but Alive says it's correct:
https://rise4fun.com/Alive/ugc

llvm-svn: 341426