platform/upstream/llvm.git
4 years agoRevert "[lit] Add -D__clang_analyzer__ to clang_analyze_cc1"
Jan Korous [Tue, 24 Sep 2019 03:20:59 +0000 (03:20 +0000)]
Revert "[lit] Add -D__clang_analyzer__ to clang_analyze_cc1"

This reverts commit 4185460f758b98ea5b898c04c179704756ca8f53.

llvm-svn: 372686

4 years agoRevert "[static analyzer][test] Test directly that driver sets D__clang_analyzer__"
Jan Korous [Tue, 24 Sep 2019 03:19:20 +0000 (03:19 +0000)]
Revert "[static analyzer][test] Test directly that driver sets D__clang_analyzer__"

This reverts commit c7541903d72765a38808e9973572a8d50c9d94fb.

llvm-svn: 372685

4 years agoFix int to bool errors exposed due to r372612.
Rumeet Dhindsa [Tue, 24 Sep 2019 02:59:02 +0000 (02:59 +0000)]
Fix int to bool errors exposed due to r372612.

Differential Revision: https://reviews.llvm.org/D67937
M    lib/builtins/fp_add_impl.inc
M    lib/builtins/fp_lib.h
M    lib/builtins/fp_trunc_impl.inc

llvm-svn: 372684

4 years ago[static analyzer][test] Test directly that driver sets D__clang_analyzer__
Jan Korous [Tue, 24 Sep 2019 02:06:59 +0000 (02:06 +0000)]
[static analyzer][test] Test directly that driver sets D__clang_analyzer__

Follow-up to fbd13570b0d

llvm-svn: 372683

4 years ago[lit] Add -D__clang_analyzer__ to clang_analyze_cc1
Jan Korous [Tue, 24 Sep 2019 01:59:20 +0000 (01:59 +0000)]
[lit] Add -D__clang_analyzer__ to clang_analyze_cc1

Fixup after fbd13570b0d

llvm-svn: 372682

4 years agoSupport for DWARF-5 C++ language tags.
Adrian Prantl [Tue, 24 Sep 2019 00:38:49 +0000 (00:38 +0000)]
Support for DWARF-5 C++ language tags.

This patch provides support for DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend.

Patch by Sourabh Singh Tomar!
Differential Revision: https://reviews.llvm.org/D67613

Reapplies r372663 after adapting a failing test in the LLDB testsuite.

llvm-svn: 372681

4 years ago[static analyzer] Remove --analyze-auto
Jan Korous [Tue, 24 Sep 2019 00:37:25 +0000 (00:37 +0000)]
[static analyzer] Remove --analyze-auto

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

llvm-svn: 372680

4 years ago[static analyzer] Define __clang_analyzer__ macro in driver
Jan Korous [Tue, 24 Sep 2019 00:33:47 +0000 (00:33 +0000)]
[static analyzer] Define __clang_analyzer__ macro in driver

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

llvm-svn: 372679

4 years ago[InstCombine] Fold a shifty implementation of clamp-to-allones.
Huihui Zhang [Tue, 24 Sep 2019 00:30:09 +0000 (00:30 +0000)]
[InstCombine] Fold a shifty implementation of clamp-to-allones.

Summary:
Fold
or(ashr(subNSW(Y, X), ScalarSizeInBits(Y)-1), X)
into
X s> Y ? -1 : X

https://rise4fun.com/Alive/d8Ab

clamp255 is a common operator in image processing, can be implemented
in a shifty way "(255 - X) >> 31 | X & 255". Fold shift into select
enables more optimization, e.g., vmin generation for ARM target.

Reviewers: lebedev.ri, efriedma, spatel, kparzysz, bcahoon

Reviewed By: lebedev.ri

Subscribers: kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372678

4 years agoAdapt test to upstream clang compiler changes.
Adrian Prantl [Tue, 24 Sep 2019 00:27:13 +0000 (00:27 +0000)]
Adapt test to upstream clang compiler changes.

Clang now emits the correct C++ language version in DWARF.

llvm-svn: 372677

4 years ago[InstCombine] Fold a shifty implementation of clamp-to-zero.
Huihui Zhang [Tue, 24 Sep 2019 00:15:03 +0000 (00:15 +0000)]
[InstCombine] Fold a shifty implementation of clamp-to-zero.

Summary:
Fold
and(ashr(subNSW(Y, X), ScalarSizeInBits(Y)-1), X)
into
X s> Y ? X : 0

https://rise4fun.com/Alive/lFH

Fold shift into select enables more optimization,
e.g., vmax generation for ARM target.

Reviewers: lebedev.ri, efriedma, spatel, kparzysz, bcahoon

Reviewed By: lebedev.ri

Subscribers: xbolva00, andreadb, craig.topper, RKSimon, kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372676

4 years ago[GlobalISel][IRTranslator] Fix switch table lowering to use signed LE not unsigned.
Amara Emerson [Tue, 24 Sep 2019 00:09:23 +0000 (00:09 +0000)]
[GlobalISel][IRTranslator] Fix switch table lowering to use signed LE not unsigned.

We were miscompiling switch value comparisons with the wrong signedness, which
shows up when we have things like switch case values with i1 types, which end up
being legalized incorrectly.

Fixes PR43383

llvm-svn: 372675

4 years ago[llvm-cov] NFC: Specify a specific C++ standard in the test.
Artem Dergachev [Tue, 24 Sep 2019 00:01:51 +0000 (00:01 +0000)]
[llvm-cov] NFC: Specify a specific C++ standard in the test.

Makes life easier for downstream users with customized default standard.

llvm-svn: 372674

4 years ago[MemorySSA] Update Phi insertion.
Alina Sbirlea [Mon, 23 Sep 2019 23:50:16 +0000 (23:50 +0000)]
[MemorySSA] Update Phi insertion.

Summary:
MemoryPhis may be needed following a Def insertion inthe IDF of all the
new accesses added (phis + potentially a def). Ensure this also  occurs when
only the new MemoryPhis are the defining accesses.

Note: The need for computing IDF here is because of new Phis added with
edges incoming from unreachable code, Phis that had previously been
simplified. The preferred solution is to not reintroduce such Phis.
This patch is the needed fix while working on the preferred solution.

Reviewers: george.burgess.iv

Subscribers: Prazek, sanjoy.google, llvm-commits

Tags: #llvm

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

llvm-svn: 372673

4 years agoRevert "Support for DWARF-5 C++ language tags."
Jonas Devlieghere [Mon, 23 Sep 2019 23:49:36 +0000 (23:49 +0000)]
Revert "Support for DWARF-5 C++ language tags."

This reverts commit bf9c8ffb54943c6d77398adbedddf05ef9724007.

llvm-svn: 372672

4 years ago[NFC][InstCombine] Add tests for shifty implementation of clamping.
Huihui Zhang [Mon, 23 Sep 2019 23:48:32 +0000 (23:48 +0000)]
[NFC][InstCombine] Add tests for shifty implementation of clamping.

Summary:
Clamp negative to zero and clamp positive to allOnes are common
operation in image saturation.

Add tests for shifty implementation of clamping, as prepare work for
folding:

and(ashr(subNSW(Y, X), ScalarSizeInBits(Y)-1), X) --> X s> 0 ? X : 0;

or(ashr(subNSW(Y, X), ScalarSizeInBits(Y)-1), X) --> X s> Y ? allOnes : X.

Reviewers: lebedev.ri, efriedma, spatel, kparzysz, bcahoon

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 372671

4 years ago[Make] Add support for building NeXT-style frameworks
Jonas Devlieghere [Mon, 23 Sep 2019 22:31:16 +0000 (22:31 +0000)]
[Make] Add support for building NeXT-style frameworks

This patch extends the Makefile.rules to build NeXT-style frameworks. It
also fixes a bug in the clean logic that would accidentally delete the
.mm source file instead of the .o object file.

Thanks a lot to Adrian who was instrumental is getting this to work!

llvm-svn: 372669

4 years ago[NFCI] Return PathSensitiveBugReport where appropriate
Alex Langford [Mon, 23 Sep 2019 22:24:47 +0000 (22:24 +0000)]
[NFCI] Return PathSensitiveBugReport where appropriate

Some compilers have trouble converting unique_ptr<PathSensitiveBugReport> to
unique_ptr<BugReport> causing some functions to fail to compile.
Changing the return type of the functions that fail to compile does not
appear to have any issues.
I ran into this issue building with clang 3.8 on Ubuntu 16.04.

llvm-svn: 372668

4 years agoHotColdSplitting: invalidate the AssumptionCache on split
Saleem Abdulrasool [Mon, 23 Sep 2019 22:23:01 +0000 (22:23 +0000)]
HotColdSplitting: invalidate the AssumptionCache on split

When a cold path is outlined, the value tracking in the assumption cache may be
invalidated due to the code motion.  We would previously trip an assertion in
subsequent passes (but required the passes to happen in a single run as the
assumption cache is shared across the passes).  Invalidating the cache ensures
that we get the correct information when needed with the legacy pass manager as
well.

llvm-svn: 372667

4 years ago[llvm-lipo] Add support for archives
Alexander Shaposhnikov [Mon, 23 Sep 2019 22:22:55 +0000 (22:22 +0000)]
[llvm-lipo] Add support for archives

Add support for creating universal binaries which
can contain an archive.

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

Test plan: make check-all

llvm-svn: 372666

4 years ago[SampleFDO] Treat names in profile as not cold only when profile symbol list
Wei Mi [Mon, 23 Sep 2019 22:11:35 +0000 (22:11 +0000)]
[SampleFDO] Treat names in profile as not cold only when profile symbol list
is available

In rL372232, we treated names showing up in profile as not cold when
profile-sample-accurate is enabled. This caused 70k size regression in
Chrome/Android. The patch put a guard and only enable the change when
profile symbol list is available, i.e., keep the old behavior when profile
symbol list is not available.

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

llvm-svn: 372665

4 years ago[Diagnostics] Warn for enum constants in bool context (-Wint-in-bool-context; GCC...
David Bolvansky [Mon, 23 Sep 2019 22:09:49 +0000 (22:09 +0000)]
[Diagnostics] Warn for enum constants in bool context (-Wint-in-bool-context; GCC compatibility)

Extracted from D63082.

llvm-svn: 372664

4 years agoSupport for DWARF-5 C++ language tags.
Adrian Prantl [Mon, 23 Sep 2019 22:01:49 +0000 (22:01 +0000)]
Support for DWARF-5 C++ language tags.

This patch provides support for DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend.

Patch by Sourabh Singh Tomar!
Differential Revision: https://reviews.llvm.org/D67613

llvm-svn: 372663

4 years agoFix uninitialized variable warning. NFCI.
Simon Pilgrim [Mon, 23 Sep 2019 21:32:38 +0000 (21:32 +0000)]
Fix uninitialized variable warning. NFCI.

llvm-svn: 372662

4 years ago[X86] Reduce the number of unique check prefixes in memset-nonzero.ll. NFC
Craig Topper [Mon, 23 Sep 2019 21:29:28 +0000 (21:29 +0000)]
[X86] Reduce the number of unique check prefixes in memset-nonzero.ll. NFC

The avx512 with prefer-256-bit generates the same code as AVX2 so
just reuse that prefix.

llvm-svn: 372661

4 years ago[lld][WebAssembly] Preserve symbol flags in --relocatable output
Sam Clegg [Mon, 23 Sep 2019 21:28:29 +0000 (21:28 +0000)]
[lld][WebAssembly] Preserve symbol flags in --relocatable output

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

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

llvm-svn: 372660

4 years ago[LLDB] [Windows] Map COFF ARM machine ids to the right triple architectures
Martin Storsjo [Mon, 23 Sep 2019 20:43:22 +0000 (20:43 +0000)]
[LLDB] [Windows] Map COFF ARM machine ids to the right triple architectures

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

llvm-svn: 372658

4 years ago[LLDB] [PECOFF] Recognize arm64 executables
Martin Storsjo [Mon, 23 Sep 2019 20:43:16 +0000 (20:43 +0000)]
[LLDB] [PECOFF] Recognize arm64 executables

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

llvm-svn: 372657

4 years ago[LLDB] Rework a MinGW build fix from D65691
Martin Storsjo [Mon, 23 Sep 2019 20:43:11 +0000 (20:43 +0000)]
[LLDB] Rework a MinGW build fix from D65691

That change didn't contain any explanation for this bit. There shouldn't
be any need for a check for MinGW ifdefs here, as long as the include
uses lowercase windows.h (as is used consistently elsewhere in
the llvm projects).

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

llvm-svn: 372656

4 years ago[WebAssembly] vNxM.load_splat instructions
Thomas Lively [Mon, 23 Sep 2019 20:42:12 +0000 (20:42 +0000)]
[WebAssembly] vNxM.load_splat instructions

Summary:
Adds the new load_splat instructions as specified at
https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#load-and-splat.

DAGISel does not allow matching multiple copies of the same load in a
single pattern, so we use a new node in WebAssemblyISD to wrap loads
that should be splatted.

Depends on D67783.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

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

llvm-svn: 372655

4 years ago[InstCombine] foldOrOfICmps(): Acquire SimplifyQuery with set CxtI
Roman Lebedev [Mon, 23 Sep 2019 20:40:47 +0000 (20:40 +0000)]
[InstCombine] foldOrOfICmps(): Acquire SimplifyQuery with set CxtI

Extracted from https://reviews.llvm.org/D67849#inline-610377

llvm-svn: 372654

4 years ago[InstCombine] foldAndOfICmps(): Acquire SimplifyQuery with set CxtI
Roman Lebedev [Mon, 23 Sep 2019 20:40:40 +0000 (20:40 +0000)]
[InstCombine] foldAndOfICmps(): Acquire SimplifyQuery with set CxtI

Extracted from https://reviews.llvm.org/D67849#inline-610377

llvm-svn: 372653

4 years agoFile::SetDescriptor() should require options
Jonas Devlieghere [Mon, 23 Sep 2019 20:36:46 +0000 (20:36 +0000)]
File::SetDescriptor() should require options

lvm_private::File::GetStream() can fail if m_options == 0

It's not clear from the header a File created with a descriptor will be
not be usable by many parts of LLDB unless SetOptions is also called,
but it is.

This is because those parts of LLDB rely on GetStream() to use the
file, and that in turn relies on calling fdopen on the descriptor. When
calling fdopen, GetStream relies on m_options to determine the access
mode. If m_options has never been set, GetStream() will fail.

This patch adds options as a required argument to File::SetDescriptor
and the corresponding constructor.

Patch by: Lawrence D'Anna

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

llvm-svn: 372652

4 years ago[mips] Support elf32btsmipn32_fbsd / elf32ltsmipn32_fbsd emulations
Simon Atanasyan [Mon, 23 Sep 2019 20:32:43 +0000 (20:32 +0000)]
[mips] Support elf32btsmipn32_fbsd / elf32ltsmipn32_fbsd emulations

Patch by Kyle Evans.

llvm-svn: 372651

4 years ago[mips] Add tests to check MIPS FreeBSD emulations. NFC
Simon Atanasyan [Mon, 23 Sep 2019 20:32:33 +0000 (20:32 +0000)]
[mips] Add tests to check MIPS FreeBSD emulations. NFC

llvm-svn: 372650

4 years ago[mips] Reformat test case to simplify addition new tests. NFC
Simon Atanasyan [Mon, 23 Sep 2019 20:32:27 +0000 (20:32 +0000)]
[mips] Reformat test case to simplify addition new tests. NFC

llvm-svn: 372649

4 years ago[WebAssembly] Remove unused memory instructions and patterns
Thomas Lively [Mon, 23 Sep 2019 20:04:59 +0000 (20:04 +0000)]
[WebAssembly] Remove unused memory instructions and patterns

Summary:
Removes duplicated SIMD loads and store instructions and removes
patterns involving GlobalAddresses that were not used in any tests.

Reviewers: aheejin, sunfish

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, jfb, llvm-commits

Tags: #llvm

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

llvm-svn: 372648

4 years ago[InstCombine] Annotate strndup calls with dereferenceable_or_null
David Bolvansky [Mon, 23 Sep 2019 19:55:45 +0000 (19:55 +0000)]
[InstCombine] Annotate strndup calls with dereferenceable_or_null

"Implementations are free to malloc() a buffer containing either (size + 1) bytes or (strnlen(s, size) + 1) bytes. Applications should not assume that strndup() will allocate (size + 1) bytes when strlen(s) is smaller than size."

llvm-svn: 372647

4 years ago[ASTImporter] 2nd attempt to fix Windows buildbot test errors
Gabor Marton [Mon, 23 Sep 2019 19:49:45 +0000 (19:49 +0000)]
[ASTImporter] 2nd attempt to fix Windows buildbot test errors

llvm-svn: 372646

4 years ago[X86] Use TargetConstant for condition code on X86ISD::SETCC/CMOV/BRCOND nodes.
Craig Topper [Mon, 23 Sep 2019 19:48:20 +0000 (19:48 +0000)]
[X86] Use TargetConstant for condition code on X86ISD::SETCC/CMOV/BRCOND nodes.

This removes the need for ConvertToTarget opcodes in the isel table.
It's also consistent with the recent changes to use TargetConstant
for intrinsic nodes that always take immediates.

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

llvm-svn: 372645

4 years ago[Host] File::GetWaitableHandle() should call fileno()
Jonas Devlieghere [Mon, 23 Sep 2019 19:34:26 +0000 (19:34 +0000)]
[Host] File::GetWaitableHandle() should call fileno()

If the file has m_stream, it may not have a m_descriptor.
GetWaitableHandle() should call GetDescriptor(), which will call
fileno(), so it will get waitable descriptor whenever one is available.

Patch by: Lawrence D'Anna

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

llvm-svn: 372644

4 years ago[ABISysV] Fix regression for Simulator and MacABI
Jonas Devlieghere [Mon, 23 Sep 2019 19:06:00 +0000 (19:06 +0000)]
[ABISysV] Fix regression for Simulator and MacABI

The ABISysV ABI was refactored in r364216 to support the Windows ABI for
x86_64. In particular it changed ABISysV_x86_64::CreateInstance to
switch on the OS type. This breaks debugging MacABI apps as well as apps
in the simulator. This adds back the necessary cases.

We have a test on Github that exercises this code path and which I'd
like to upstream once the remaining MacABI parts become available in
clang.

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

llvm-svn: 372642

4 years ago[TableGen] Emit OperandType enums for RegisterOperands/RegisterClasses
Aditya Nandakumar [Mon, 23 Sep 2019 18:51:00 +0000 (18:51 +0000)]
[TableGen] Emit OperandType enums for RegisterOperands/RegisterClasses

https://reviews.llvm.org/D66773

The OpTypes::OperandType was creating an enum for all records that
inherit from Operand, but in reality there are operands for instructions
that inherit from other types too. In particular, RegisterOperand and
RegisterClass. This commit adds those types to the list of operand types
that are tracked by the OperandType enum.

Patch by: nlguillemot

llvm-svn: 372641

4 years ago[Sema] Fix the atomic expr rebuilding order.
Michael Liao [Mon, 23 Sep 2019 18:48:06 +0000 (18:48 +0000)]
[Sema] Fix the atomic expr rebuilding order.

Summary:
- Rearrange the atomic expr order to the API order when rebuilding
  atomic expr during template instantiation.

Reviewers: erichkeane

Subscribers: jfb, cfe-commits

Tags: #clang

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

llvm-svn: 372640

4 years ago[IR] Add getExtendedType() to IntegerType and Type (dispatching to IntegerType or...
Roman Lebedev [Mon, 23 Sep 2019 18:21:33 +0000 (18:21 +0000)]
[IR] Add getExtendedType() to IntegerType and Type (dispatching to IntegerType or VectorType)

llvm-svn: 372638

4 years ago[InstCombine] dropRedundantMaskingOfLeftShiftInput(): improve comment
Roman Lebedev [Mon, 23 Sep 2019 18:21:14 +0000 (18:21 +0000)]
[InstCombine] dropRedundantMaskingOfLeftShiftInput(): improve comment

llvm-svn: 372637

4 years ago[SLC] Convert some strndup calls to strdup calls
David Bolvansky [Mon, 23 Sep 2019 18:20:01 +0000 (18:20 +0000)]
[SLC] Convert some strndup calls to strdup calls

Summary:
Motivation:
- If we can fold it to strdup, we should (strndup does more things than strdup).
- Annotation mechanism. (Works for strdup well).

strdup and strndup are part of C 20 (currently posix fns), so we should optimize them.

Reviewers: efriedma, jdoerfert

Reviewed By: jdoerfert

Subscribers: lebedev.ri, llvm-commits

Tags: #llvm

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

llvm-svn: 372636

4 years ago[OPENMP]Use standard parsing for 'match' clause, NFC.
Alexey Bataev [Mon, 23 Sep 2019 18:13:31 +0000 (18:13 +0000)]
[OPENMP]Use standard parsing for 'match' clause, NFC.

Reused standard clauses parsing scheme for parsing/matching 'match'
clause in 'declare variant' directive.

llvm-svn: 372635

4 years ago[lldb-suite] TestCallOverriddenMethod.py is now passing on Windows
Stella Stamenova [Mon, 23 Sep 2019 17:51:27 +0000 (17:51 +0000)]
[lldb-suite] TestCallOverriddenMethod.py is now passing on Windows

The test is now passing, so remove the expected failure. No other tests associated with the bug are passing, though, so only remove expected failure from this one test

llvm-svn: 372634

4 years ago[ASTImporter] Attempt to fix Windows buildbot test errors
Gabor Marton [Mon, 23 Sep 2019 17:29:08 +0000 (17:29 +0000)]
[ASTImporter] Attempt to fix Windows buildbot test errors

llvm-svn: 372633

4 years ago[libc++] Mark CTAD tests as not failing on AppleClang 10.0.1
Louis Dionne [Mon, 23 Sep 2019 17:22:13 +0000 (17:22 +0000)]
[libc++] Mark CTAD tests as not failing on AppleClang 10.0.1

They do fail on AppleClang 10.0.0, but not AppleClang 10.0.1

llvm-svn: 372632

4 years agoNFC: Fix a poorly-written test
Erik Pilkington [Mon, 23 Sep 2019 17:16:55 +0000 (17:16 +0000)]
NFC: Fix a poorly-written test

The author of r364954 foolishly forgot that == binds tighter than ?:

llvm-svn: 372631

4 years ago[InstCombine] dropRedundantMaskingOfLeftShiftInput(): pat. c/d/e with mask (PR42563)
Roman Lebedev [Mon, 23 Sep 2019 17:04:28 +0000 (17:04 +0000)]
[InstCombine] dropRedundantMaskingOfLeftShiftInput(): pat. c/d/e with mask (PR42563)

Summary:
If we have a pattern `(x & (-1 >> maskNbits)) << shiftNbits`,
we already know (have a fold) that will drop the `& (-1 >> maskNbits)`
mask iff `(shiftNbits-maskNbits) s>= 0` (i.e. `shiftNbits u>= maskNbits`).

So even if `(shiftNbits-maskNbits) s< 0`, we can still
fold, we will just need to apply a **constant** mask afterwards:
```
Name: c, normal+mask
  %t0 = lshr i32 -1, C1
  %t1 = and i32 %t0, %x
  %r = shl i32 %t1, C2
=>
  %n0 = shl i32 %x, C2
  %n1 = i32 ((-(C2-C1))+32)
  %n2 = zext i32 %n1 to i64
  %n3 = lshr i64 -1, %n2
  %n4 = trunc i64 %n3 to i32
  %r = and i32 %n0, %n4
```
https://rise4fun.com/Alive/gslRa

Naturally, old `%masked` will have to be one-use.
This is not valid for pattern f - where "masking" is done via `ashr`.

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

Reviewers: spatel, nikic, xbolva00

Reviewed By: spatel

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372630

4 years ago[InstCombine] dropRedundantMaskingOfLeftShiftInput(): pat. a/b with mask (PR42563)
Roman Lebedev [Mon, 23 Sep 2019 17:04:14 +0000 (17:04 +0000)]
[InstCombine] dropRedundantMaskingOfLeftShiftInput(): pat. a/b with mask (PR42563)

Summary:
And this is **finally** the interesting part of that fold!

If we have a pattern `(x & (~(-1 << maskNbits))) << shiftNbits`,
we already know (have a fold) that will drop the `& (~(-1 << maskNbits))`
mask iff `(maskNbits+shiftNbits) u>= bitwidth(x)`.
But that is actually ignorant, there's more general fold here:

In this pattern, `(maskNbits+shiftNbits)` actually correlates
with the number of low bits that will remain in the final value.
So even if `(maskNbits+shiftNbits) u< bitwidth(x)`, we can still
fold, we will just need to apply a **constant** mask afterwards:
```
Name: a, normal+mask
  %onebit = shl i32 -1, C1
  %mask = xor i32 %onebit, -1
  %masked = and i32 %mask, %x
  %r = shl i32 %masked, C2
=>
  %n0 = shl i32 %x, C2
  %n1 = add i32 C1, C2
  %n2 = zext i32 %n1 to i64
  %n3 = shl i64 -1, %n2
  %n4 = xor i64 %n3, -1
  %n5 = trunc i64 %n4 to i32
  %r = and i32 %n0, %n5
```
https://rise4fun.com/Alive/F5R

Naturally, old `%masked` will have to be one-use.
Similar fold exists for patterns c,d,e, will post patch later.

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

Reviewers: spatel, nikic, xbolva00

Reviewed By: spatel

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372629

4 years ago[BreakFalseDeps] ignore function with minsize attribute
Sanjay Patel [Mon, 23 Sep 2019 17:01:01 +0000 (17:01 +0000)]
[BreakFalseDeps] ignore function with minsize attribute

This came up in the x86-specific:
https://bugs.llvm.org/show_bug.cgi?id=43239
...but it is a general problem for the BreakFalseDeps pass.
Dependencies may be broken by adding some other instruction,
so that should be avoided if the overall goal is to minimize size.

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

llvm-svn: 372628

4 years ago[Clang-doc] NFC: Fixed link to llvm bugs in documentation
Shaurya Gupta [Mon, 23 Sep 2019 16:55:13 +0000 (16:55 +0000)]
[Clang-doc] NFC: Fixed link to llvm bugs in documentation

llvm-svn: 372627

4 years ago[SLP] Fix for PR31847: Assertion failed: (isLoopInvariant(Operands[i], L) && "SCEVAdd...
Alexey Bataev [Mon, 23 Sep 2019 16:25:03 +0000 (16:25 +0000)]
[SLP] Fix for PR31847: Assertion failed: (isLoopInvariant(Operands[i], L) && "SCEVAddRecExpr operand is not loop-invariant!")

Summary:
Initially SLP vectorizer replaced all going-to-be-vectorized
instructions with Undef values. It may break ScalarEvaluation and may
cause a crash.
Reworked SLP vectorizer so that it does not replace vectorized
instructions by UndefValue anymore. Instead vectorized instructions are
marked for deletion inside if BoUpSLP class and deleted upon class
destruction.

Reviewers: mzolotukhin, mkuper, hfinkel, RKSimon, davide, spatel

Subscribers: RKSimon, Gerolf, anemet, hans, majnemer, llvm-commits, sanjoy

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

llvm-svn: 372626

4 years ago[InstCombine] foldUnsignedUnderflowCheck(): s/Subtracted/ZeroCmpOp/
Roman Lebedev [Mon, 23 Sep 2019 16:04:32 +0000 (16:04 +0000)]
[InstCombine] foldUnsignedUnderflowCheck(): s/Subtracted/ZeroCmpOp/

llvm-svn: 372625

4 years ago Fix __is_fundamental to accept nullptr_t
Zoe Carver [Mon, 23 Sep 2019 16:02:46 +0000 (16:02 +0000)]
Fix __is_fundamental to accept nullptr_t

    Summary: This patch updates the __is_fundamental builtin type trait to return true for nullptr_t.

    Reviewers: rsmith, EricWF, efriedma, craig.topper, erichkeane

    Subscribers: cfe-commits

    Tags: #clang

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

llvm-svn: 372624

4 years ago[OPENMP]Fix PR43355: DO not emit target calls if only -fopenmp-targets
Alexey Bataev [Mon, 23 Sep 2019 15:53:51 +0000 (15:53 +0000)]
[OPENMP]Fix PR43355: DO not emit target calls if only -fopenmp-targets
is not provided.

We should not emit any target-dependent code if only -fopenmp flag is
used and device targets are not provided to prevent compiler crash.

llvm-svn: 372623

4 years ago[AMDGPU][MC] Corrected handling of relocatable expressions
Dmitry Preobrazhensky [Mon, 23 Sep 2019 15:41:51 +0000 (15:41 +0000)]
[AMDGPU][MC] Corrected handling of relocatable expressions

See bug 43359: https://bugs.llvm.org//show_bug.cgi?id=43359

Reviewers: rampitec

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

llvm-svn: 372622

4 years ago Fix __is_signed builtin
Zoe Carver [Mon, 23 Sep 2019 15:41:20 +0000 (15:41 +0000)]
Fix __is_signed builtin

    Summary: This patch fixes the __is_signed builtin type trait to work with floating point types and enums. Now, the builtin will return true if it is passed a floating point type and false for an enum type.

    Reviewers: EricWF, rsmith, erichkeane, craig.topper, efriedma

    Subscribers: cfe-commits

    Tags: #clang

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

llvm-svn: 372621

4 years ago[libc++] Mark iostreams test as XFAIL on older macOSes
Louis Dionne [Mon, 23 Sep 2019 15:40:47 +0000 (15:40 +0000)]
[libc++] Mark iostreams test as XFAIL on older macOSes

llvm-svn: 372620

4 years agoHexagonLoopIdiomRecognition - silence static analyzer dyn_cast<> null dereference...
Simon Pilgrim [Mon, 23 Sep 2019 15:36:24 +0000 (15:36 +0000)]
HexagonLoopIdiomRecognition - silence static analyzer dyn_cast<> null dereference warnings. NFCI.

llvm-svn: 372619

4 years ago[TextAPI] Add New Supported Platforms
Cyndy Ishida [Mon, 23 Sep 2019 15:28:02 +0000 (15:28 +0000)]
[TextAPI] Add New Supported Platforms

Summary: This patch introduces simulators, as well was the restriced zippered and macCatalyst to supported platforms

Reviewers: ributzka, steven_wu

Reviewed By: ributzka

Subscribers: hiraditya, dexonsmith, llvm-commits

Tags: #llvm

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

llvm-svn: 372618

4 years ago[clangd] Simplify the callside of URI::resolve, NFC.
Haojian Wu [Mon, 23 Sep 2019 14:39:37 +0000 (14:39 +0000)]
[clangd] Simplify the callside of URI::resolve, NFC.

Summary:
- Add a overrloded URI::resolve, which accepts a string URI;
- also fixed some callside that don't check the error;

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 372617

4 years ago[Hexagon] Bitcast v4i16 to v8i8, unify no-op casts between scalar and HVX
Krzysztof Parzyszek [Mon, 23 Sep 2019 14:33:27 +0000 (14:33 +0000)]
[Hexagon] Bitcast v4i16 to v8i8, unify no-op casts between scalar and HVX

llvm-svn: 372616

4 years ago[docs] Fix some typos in InternalsManual
Sven van Haastregt [Mon, 23 Sep 2019 14:24:29 +0000 (14:24 +0000)]
[docs] Fix some typos in InternalsManual

llvm-svn: 372614

4 years ago[Alignment][NFC] Migrate Instructions to Align
Guillaume Chatelet [Mon, 23 Sep 2019 14:23:37 +0000 (14:23 +0000)]
[Alignment][NFC] Migrate Instructions to Align

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372613

4 years ago[Diagnostics] Warn if '<<' in bool context with -Wint-in-bool-context (GCC compatibility)
David Bolvansky [Mon, 23 Sep 2019 14:21:08 +0000 (14:21 +0000)]
[Diagnostics] Warn if '<<' in bool context with -Wint-in-bool-context (GCC compatibility)

Extracted from D63082, addressed review comments related to a warning message.

llvm-svn: 372612

4 years agoFix test atomic-expr.cpp after R372422
Erich Keane [Mon, 23 Sep 2019 14:12:13 +0000 (14:12 +0000)]
Fix test atomic-expr.cpp after R372422

The test tried to match a path in a printout by doing '^:' which failed
on windows, since C:\... is a path.

llvm-svn: 372611

4 years ago[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
Simon Pilgrim [Mon, 23 Sep 2019 14:11:48 +0000 (14:11 +0000)]
[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library

Modify LLVMConfig to produce LLVM_USE_CRT variables in build-directory. It helps to set the same compiler debug options like in builded library.

Committed on behalf of @igorban (Igor)

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

llvm-svn: 372610

4 years ago[OPENMP]Call __kmpc_push_tripcount in task context.
Alexey Bataev [Mon, 23 Sep 2019 14:06:51 +0000 (14:06 +0000)]
[OPENMP]Call __kmpc_push_tripcount in task context.

Runtime function __kmpc_push_tripcount better to call inside of the task
context for target regions. Otherwise, the libomptarget is unable to
link the provided tripcount value for nowait target regions and
completely looses this information.

llvm-svn: 372609

4 years ago[LLDB] Fix logically dead code
Konrad Kleine [Mon, 23 Sep 2019 14:05:51 +0000 (14:05 +0000)]
[LLDB] Fix logically dead code

Summary:
The indicated dead code may have performed some action; that action will never occur.

In lldb_private::LoadedModuleInfoList::LoadedModuleInfo::operator ==(lldb_private::LoadedModuleInfoList::LoadedModuleInfo const &): Code can never be reached because of a logical contradiction (CWE-561)

Coverity Scan: https://scan.coverity.com/projects/kwk-llvm-project?tab=overview

CID 221581

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 372608

4 years agoAdded a test for agreement between paths used in ClangTidy's diagnostics and header...
Dmitri Gribenko [Mon, 23 Sep 2019 13:44:42 +0000 (13:44 +0000)]
Added a test for agreement between paths used in ClangTidy's diagnostics and header filter

This test would have been broken by r372388.

llvm-svn: 372607

4 years ago[x86] fix assert with horizontal math + broadcast of vector (PR43402)
Sanjay Patel [Mon, 23 Sep 2019 13:30:23 +0000 (13:30 +0000)]
[x86] fix assert with horizontal math + broadcast of vector (PR43402)

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

llvm-svn: 372606

4 years ago[libTooling] Add `access` and `ifBound` combinators to Stencil library.
Yitzhak Mandelbaum [Mon, 23 Sep 2019 13:21:42 +0000 (13:21 +0000)]
[libTooling] Add `access` and `ifBound` combinators to Stencil library.

Summary:
This revision add the `access` and `ifBound` combinators to the Stencil library:
* `access` -- constructs an idiomatic expression for accessing a member (a
  `MemberExpr`).
* `ifBound` -- chooses between two `StencilParts` based on the whether an id is
  bound in the match (corresponds to the combinator of the same name in
  RangeSelector).

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 372605

4 years ago[ValueTracking] Remove unused matchSelectPattern optional argument. NFCI.
Simon Pilgrim [Mon, 23 Sep 2019 13:20:47 +0000 (13:20 +0000)]
[ValueTracking] Remove unused matchSelectPattern optional argument. NFCI.

The matchSelectPattern const wrapper is never explicitly called with the optional Instruction::CastOps argument, and it turns out that it wasn't being forwarded to matchSelectPattern anyway!

Noticed while investigating clang static analyzer warnings.

llvm-svn: 372604

4 years ago[ValueTracking] Fix uninitialized variable warnings in matchSelectPattern const wrapp...
Simon Pilgrim [Mon, 23 Sep 2019 13:15:52 +0000 (13:15 +0000)]
[ValueTracking] Fix uninitialized variable warnings in matchSelectPattern const wrapper. NFCI.

Static analyzer complains about const_cast uninitialized variables, we should explicitly set these to null.

Ideally that const wrapper would go away though.......

llvm-svn: 372603

4 years agollvm-undname: Add support for demangling typeinfo names
Nico Weber [Mon, 23 Sep 2019 13:13:37 +0000 (13:13 +0000)]
llvm-undname: Add support for demangling typeinfo names

typeinfo names aren't symbols but string constant contents
stored in compiler-generated typeinfo objects, but llvm-cxxfilt
can demangle these for Itanium names.

In the MSVC ABI, these are just a '.' followed by a mangled
type -- this means they don't start with '?' like all MS-mangled
symbols do.

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

llvm-svn: 372602

4 years agoRevert "[clang-tidy] Fix relative path in header-filter."
Dmitri Gribenko [Mon, 23 Sep 2019 13:06:25 +0000 (13:06 +0000)]
Revert "[clang-tidy] Fix relative path in header-filter."

This reverts commit r372388. It made '-header-filter' inconsistent with
paths printed in diagnostics.

llvm-svn: 372601

4 years ago[Diagnostics] Avoid -Wsizeof-array-div when dividing the size of a nested array by...
David Bolvansky [Mon, 23 Sep 2019 12:54:35 +0000 (12:54 +0000)]
[Diagnostics] Avoid -Wsizeof-array-div when dividing the size of a nested array by the size of the deepest base type

llvm-svn: 372600

4 years agoCosmetic; don't use the magic constant 35 when HASH is more readable. This matches...
Mark Murray [Mon, 23 Sep 2019 12:52:42 +0000 (12:52 +0000)]
Cosmetic; don't use the magic constant 35 when HASH is more readable. This matches other MCK__<THING>_* usage better.

Summary: No functional change. This fixes a magic constant in MCK__*_... macros only.

Reviewers: ostannard

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372599

4 years agoFunction::BuildLazyArguments() - fix "variable used but never read" analyzer warning...
Simon Pilgrim [Mon, 23 Sep 2019 12:49:39 +0000 (12:49 +0000)]
Function::BuildLazyArguments() - fix "variable used but never read" analyzer warning. NFCI.

Simplify the code by separating the masking of the SDC variable from using it.

llvm-svn: 372598

4 years agogn build: Merge r372595
GN Sync Bot [Mon, 23 Sep 2019 12:44:45 +0000 (12:44 +0000)]
gn build: Merge r372595

llvm-svn: 372597

4 years ago[Alignment][NFC] DataLayout migration to llvm::Align
Guillaume Chatelet [Mon, 23 Sep 2019 12:41:36 +0000 (12:41 +0000)]
[Alignment][NFC] DataLayout migration to llvm::Align

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: jholewinski, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372596

4 years ago[libTooling] Introduce new library of source-code builders.
Yitzhak Mandelbaum [Mon, 23 Sep 2019 12:40:10 +0000 (12:40 +0000)]
[libTooling] Introduce new library of source-code builders.

Summary:
Introduces facilities for easily building source-code strings, including
idiomatic use of parentheses and the address-of, dereference and member-access
operators (dot and arrow) and queries about need for parentheses.

Reviewers: gribozavr

Subscribers: mgorny, cfe-commits, ilya-biryukov

Tags: #clang

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

llvm-svn: 372595

4 years agoRemoved dead code from Stencil.h
Dmitri Gribenko [Mon, 23 Sep 2019 12:15:48 +0000 (12:15 +0000)]
Removed dead code from Stencil.h

llvm-svn: 372594

4 years agoRemoved an incorred namespace-end comment
Dmitri Gribenko [Mon, 23 Sep 2019 12:07:10 +0000 (12:07 +0000)]
Removed an incorred namespace-end comment

llvm-svn: 372593

4 years ago[LLDB] Check for _WIN32 instead of _MSC_VER for code specific to windows in general
Martin Storsjo [Mon, 23 Sep 2019 12:03:56 +0000 (12:03 +0000)]
[LLDB] Check for _WIN32 instead of _MSC_VER for code specific to windows in general

These ifdefs contain code that isn't specific to MSVC but useful for
any windows target, like MinGW.

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

llvm-svn: 372592

4 years ago[LLDB] Remove a now redundant windows specific workaround
Martin Storsjo [Mon, 23 Sep 2019 12:03:33 +0000 (12:03 +0000)]
[LLDB] Remove a now redundant windows specific workaround

vsnprintf(NULL, 0, ...) works for measuring the needed string
size on all supported Windows variants; it's supported since
at least MSVC 2015 (and LLVM requires a newer version than that),
and works on both msvcrt.dll (since at least XP) and UCRT with MinGW.

The previous use of ifdefs was wrong as well, as __MINGW64__ only is
defined for 64 bit targets, and the define without trailing
underscores is never defined automatically (neither by clang nor
by gcc).

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

llvm-svn: 372591

4 years ago[LLDB] Add a void* cast when passing object pointers to printf %p
Martin Storsjo [Mon, 23 Sep 2019 12:03:28 +0000 (12:03 +0000)]
[LLDB] Add a void* cast when passing object pointers to printf %p

This fixes build warnings in MinGW mode.

Also remove leftover if (log) {} around the log macro.

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

llvm-svn: 372590

4 years ago[LLDB] Avoid a warning about an unused static variable
Martin Storsjo [Mon, 23 Sep 2019 12:03:21 +0000 (12:03 +0000)]
[LLDB] Avoid a warning about an unused static variable

The variable is unused on windows.

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

llvm-svn: 372589

4 years ago[LLDB] Remove a stray semicolon. NFC.
Martin Storsjo [Mon, 23 Sep 2019 12:03:14 +0000 (12:03 +0000)]
[LLDB] Remove a stray semicolon. NFC.

This fixes build warnings with at least GCC.

llvm-svn: 372588

4 years ago[LLDB] Add a missing specification of linking against dbghelp
Martin Storsjo [Mon, 23 Sep 2019 12:03:08 +0000 (12:03 +0000)]
[LLDB] Add a missing specification of linking against dbghelp

The PECOFF object file plugin uses the dbghelp API, but doesn't
specify that it has to be linked in anywhere.

Current MSVC based builds have probably succeeded, as other parts
in LLDB have had a "#pragma comment(lib, "dbghelp.lib")", but there's
currently no such pragma in the PECOFF plugin.

The "#pragma comment(lib, ...)" approach doesn't work in MinGW mode
(unless the compiler is given the -fms-extensions option, and even
then, it's only supported by clang/lld, not by GCC/binutils), thus
add it to be linked via CMake. (The other parts of LLDB that use
dbghelp are within _MSC_VER ifdefs.)

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

llvm-svn: 372587

4 years ago[LLDB] Use the Windows SOCKET type on all windows targets, not only MSVC
Martin Storsjo [Mon, 23 Sep 2019 12:02:59 +0000 (12:02 +0000)]
[LLDB] Use the Windows SOCKET type on all windows targets, not only MSVC

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

llvm-svn: 372586

4 years ago[Alignment] Get DataLayout::StackAlignment as Align
Guillaume Chatelet [Mon, 23 Sep 2019 12:01:32 +0000 (12:01 +0000)]
[Alignment] Get DataLayout::StackAlignment as Align

Summary:
Internally it is needed to know if StackAlignment is set but we can
expose it as llvm::Align.

This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372585

4 years agoLocalizer - fix "variable used but never read" analyzer warning. NFCI.
Simon Pilgrim [Mon, 23 Sep 2019 11:38:10 +0000 (11:38 +0000)]
Localizer - fix "variable used but never read" analyzer warning. NFCI.

Simplify the code by separating the modification of the Changed variable from returning it.

llvm-svn: 372583

4 years agoTargetInstrInfo::getStackSlotRange - fix "variable used but never read" analyzer...
Simon Pilgrim [Mon, 23 Sep 2019 11:36:24 +0000 (11:36 +0000)]
TargetInstrInfo::getStackSlotRange - fix "variable used but never read" analyzer warning. NFCI.

We don't need to divide the BitSize local variable at all.

llvm-svn: 372582

4 years agogn build: Merge r372564
GN Sync Bot [Mon, 23 Sep 2019 11:08:25 +0000 (11:08 +0000)]
gn build: Merge r372564

llvm-svn: 372581