platform/upstream/llvm.git
6 years ago[X86] Merge ADDSUB/SUBADD detection into single methods that can detect either and...
Craig Topper [Fri, 16 Mar 2018 18:25:59 +0000 (18:25 +0000)]
[X86] Merge ADDSUB/SUBADD detection into single methods that can detect either and indicate what they found.

Previously, we called the same functions twice with a bool flag determining whether we should look for ADDSUB or SUBADD. It would be more efficient to run the code once and detect either pattern with a flag to tell which type it found.

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

llvm-svn: 327730

6 years agoRemove -gmodules restriction from test
Adrian Prantl [Fri, 16 Mar 2018 18:21:48 +0000 (18:21 +0000)]
Remove -gmodules restriction from test

llvm-svn: 327729

6 years ago[CorrelatedValuePropagation] Use SelectInst::getCondition/getTrueValue/getFalseValue...
Craig Topper [Fri, 16 Mar 2018 18:18:47 +0000 (18:18 +0000)]
[CorrelatedValuePropagation] Use SelectInst::getCondition/getTrueValue/getFalseValue instead of getOperand for readability. NFC

llvm-svn: 327728

6 years ago[analyzer] Fix crashes in RetainCountChecker when underlying region is not a var
George Karpenkov [Fri, 16 Mar 2018 18:16:47 +0000 (18:16 +0000)]
[analyzer] Fix crashes in RetainCountChecker when underlying region is not a var

For other regions, the error message contains a good indication of the
problem, and there, in general, nothing helpful we can print.
Error pointer to the problematic expression seems enough.

rdar://37323555

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

llvm-svn: 327727

6 years ago[AMDGPU] Supported ds_write_b128 generation.
Farhana Aleen [Fri, 16 Mar 2018 18:12:00 +0000 (18:12 +0000)]
[AMDGPU] Supported ds_write_b128 generation.

Summary: This is a follow-on patch of https://reviews.llvm.org/D44210

Author: FarhanaAleen

Reviewed By: msearles

Subscribers: llvm-commits, AMDGPU

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

llvm-svn: 327726

6 years ago[docs] ReleaseNotes: document -Wextra-semi changes.
Roman Lebedev [Fri, 16 Mar 2018 18:01:07 +0000 (18:01 +0000)]
[docs] ReleaseNotes: document -Wextra-semi changes.

I should have done it in rL327558 / D43162, but forgot..

I'm not 100% sure about the text, but i don't think
it warrants a whole new differential revision.

llvm-svn: 327725

6 years ago[X86] Post process the DAG after isel to remove vector moves that were added to zero...
Craig Topper [Fri, 16 Mar 2018 17:13:42 +0000 (17:13 +0000)]
[X86] Post process the DAG after isel to remove vector moves that were added to zero upper bits.

We previously avoided inserting these moves during isel in a few cases which is implemented using a whitelist of opcodes. But it's too difficult to generate a perfect list of opcodes to whitelist. Especially with AVX512F without AVX512VL using 512 bit vectors to implement some 128/256 bit operations. Since isel is done bottoms up, we'd have to check the VT and opcode and subtarget in order to determine whether an EXTRACT_SUBREG would be generated for some operations.

So instead of doing that, this patch adds a post processing step that detects when the moves are unnecesssary after isel. At that point any EXTRACT_SUBREGs would have already been created and appear in the DAG. So then we just need to ensure the input to the move isn't one.

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

llvm-svn: 327724

6 years ago[AMDGPU][MC][GFX8][GFX9][DISASSEMBLER] Added "_e32" suffix to 32-bit VINTRP opcodes
Dmitry Preobrazhensky [Fri, 16 Mar 2018 16:38:04 +0000 (16:38 +0000)]
[AMDGPU][MC][GFX8][GFX9][DISASSEMBLER] Added "_e32" suffix to 32-bit VINTRP opcodes

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

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

Reviewers: artem.tamazov, arsenm
llvm-svn: 327723

6 years ago[LICM/mustexec] Extend first iteration must execute logic to fcmps
Philip Reames [Fri, 16 Mar 2018 16:33:49 +0000 (16:33 +0000)]
[LICM/mustexec] Extend first iteration must execute logic to fcmps

This builds on the work from https://reviews.llvm.org/D44287. It turned out supporting fcmp was much easier than I realized, so let's do that now.

As an aside, our -O3 handling of a floating point IVs leaves a lot to be desired. We do convert the float IV to an integer IV, but do so late enough that many other optimizations are missed (e.g. we don't vectorize).

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

llvm-svn: 327722

6 years agoThis patch fixes the invalid usage of OptSize in Machine Combiner.
Andrew V. Tischenko [Fri, 16 Mar 2018 16:06:24 +0000 (16:06 +0000)]
This patch fixes the invalid usage of OptSize in Machine Combiner.
Differential Revision: https://reviews.llvm.org/D43813

llvm-svn: 327721

6 years ago[AMDGPU][MC] Corrected default values for unused SDWA operands
Dmitry Preobrazhensky [Fri, 16 Mar 2018 15:40:27 +0000 (15:40 +0000)]
[AMDGPU][MC] Corrected default values for unused SDWA operands

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

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

Reviewers: artem.tamazov, arsenm
llvm-svn: 327720

6 years agoRevert "Mmap interceptor new option, Write Exec runtime detector"
Jonas Devlieghere [Fri, 16 Mar 2018 15:34:09 +0000 (15:34 +0000)]
Revert "Mmap interceptor new option, Write Exec runtime detector"

This reverts r327696 because it is failing on GreenDragon.

  http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/43605/
  http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/10957/

llvm-svn: 327719

6 years ago[InstCombine] add nnan requirement to potential fabs folds tests; NFC
Sanjay Patel [Fri, 16 Mar 2018 15:27:39 +0000 (15:27 +0000)]
[InstCombine] add nnan requirement to potential fabs folds tests; NFC

As noted in D44550, we can't guarantee preserving the sign-bit of NaN
if we convert these to fabs().

llvm-svn: 327718

6 years ago[clangd] Handle multiple callbacks from Sema's completion
Ilya Biryukov [Fri, 16 Mar 2018 15:23:44 +0000 (15:23 +0000)]
[clangd] Handle multiple callbacks from Sema's completion

Summary:
When parser backtracks, we might receive multiple code completion
callbacks.
Previously we had a failing assertion there, now we take first results
and hope they are good enough.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, jkorous-apple, ioeric, cfe-commits

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

llvm-svn: 327717

6 years ago[clang-format] Disallow breaks before ']' in text proto extensions
Krasimir Georgiev [Fri, 16 Mar 2018 15:23:22 +0000 (15:23 +0000)]
[clang-format] Disallow breaks before ']' in text proto extensions

Summary: This disallows patterns like `[ext.name\n]` in text protos.

Subscribers: klimek, cfe-commits

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

llvm-svn: 327716

6 years ago[SystemZ] Make AnyRegBitRegClass unallocatable.
Jonas Paulsson [Fri, 16 Mar 2018 15:21:26 +0000 (15:21 +0000)]
[SystemZ]  Make AnyRegBitRegClass unallocatable.

AnyReg is just for the assembler and it is better to have it as not
allocatable in order to simplify (make more intuitive) the RegPressureSets.

Review: Ulrich Weigand
llvm-svn: 327715

6 years ago[GISel]: Remove unused header include in MachineIRBuilder.h
Aditya Nandakumar [Fri, 16 Mar 2018 15:14:18 +0000 (15:14 +0000)]
[GISel]: Remove unused header include in MachineIRBuilder.h

llvm-svn: 327714

6 years ago[JumpThreading] Track unreachable BBs to avoid processing
Brian M. Rzycki [Fri, 16 Mar 2018 15:13:47 +0000 (15:13 +0000)]
[JumpThreading] Track unreachable BBs to avoid processing

JumpThreading iterates over F until the IR quiesces. Transforming
unreachable BBs increases compile time and it is also possible to
never stabilize causing JumpThreading to hang. An older attempt at
fixing this problem was D3991 where removeUnreachableBlocks(F)
was called before JumpThreading began. This has a few drawbacks:
 * expensive - the routine attempts to fix up the IR to identify
   additional BBs that can be removed along with unreachable BBs.
 * aggressive - does not identify and preserve the shape of the IR.
   At a minimum it does not preserve loop hierarchies.
 * invasive - altering reachable blocks it may disrupt IR shapes
   that could have otherwise been JumpThreaded.

This patch avoids removeUnreachableBlocks(F) and instead tracks
unreachable BBs in a SmallPtrSet using DominatorTree to validate the
initial state of all BBs. We then rely on subsequent passes to identify
and remove these unreachable blocks from F.

Reviewers: dberlin, sebpop, kuhar, dinesh.d

Reviewed by: sebpop, kuhar

Subscribers: hiraditya, uabelho, llvm-commits

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

llvm-svn: 327713

6 years ago[Hexagon] Fix zero-extending non-HVX bool vectors
Krzysztof Parzyszek [Fri, 16 Mar 2018 15:03:37 +0000 (15:03 +0000)]
[Hexagon] Fix zero-extending non-HVX bool vectors

llvm-svn: 327712

6 years agoMove DraftMgr from ClangdServer to ClangdLSPServer
Simon Marchi [Fri, 16 Mar 2018 14:30:42 +0000 (14:30 +0000)]
Move DraftMgr from ClangdServer to ClangdLSPServer

Summary:
This patch moves the draft manager closer to the edge of Clangd, from
ClangdServer to ClangdLSPServer.  This will make it easier to implement
incremental document sync, by making ClangdServer only deal with
complete documents.

As a result, DraftStore doesn't have to deal with versioning, and thus
its API can be simplified.  It is replaced by a StringMap in
ClangdServer holding a current version number for each file.

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
Subscribers: klimek, mgorny, ilya-biryukov, jkorous-apple, ioeric, cfe-commits

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

llvm-svn: 327711

6 years ago[ARM] Convert more invalid NEON immediate loads
Mikhail Maltsev [Fri, 16 Mar 2018 14:10:56 +0000 (14:10 +0000)]
[ARM] Convert more invalid NEON immediate loads

Summary:
Currently the LLVM MC assembler is able to convert e.g.

  vmov.i32 d0, #0xabababab

(which is technically invalid) into a valid instruction

  vmov.i8 d0, #0xab

this patch adds support for vmov.i64 and for cases with the resulting
load types other than i8, e.g.:

  vmov.i32 d0, #0xab00ab00 ->
  vmov.i16 d0, #0xab00

Reviewers: olista01, rengolin

Reviewed By: rengolin

Subscribers: rengolin, javed.absar, kristof.beyls, rogfer01, llvm-commits

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

llvm-svn: 327709

6 years ago[clang-format] Fix raw string prefix penalty
Krasimir Georgiev [Fri, 16 Mar 2018 14:01:25 +0000 (14:01 +0000)]
[clang-format] Fix raw string prefix penalty

Summary: We weren't penalizing cases where the raw string prefix goes over the column limit.

Subscribers: klimek, cfe-commits

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

llvm-svn: 327708

6 years ago[X86][Btver2] Add correct mul/imul schedule costs
Simon Pilgrim [Fri, 16 Mar 2018 14:01:01 +0000 (14:01 +0000)]
[X86][Btver2] Add correct mul/imul schedule costs

Integer multiply is performed on the JMul function unit and i64 requires double pumping

llvm-svn: 327707

6 years ago[X86][Btver2] Add correct lzcnt/tzcnt/popcnt schedule costs
Simon Pilgrim [Fri, 16 Mar 2018 13:43:55 +0000 (13:43 +0000)]
[X86][Btver2] Add correct lzcnt/tzcnt/popcnt schedule costs

Don't use WriteIMul defaults

llvm-svn: 327706

6 years agoImplement C++ DR727, which permits explicit specializations at class scope.
Richard Smith [Fri, 16 Mar 2018 13:36:56 +0000 (13:36 +0000)]
Implement C++ DR727, which permits explicit specializations at class scope.

More generally, this permits a template to be specialized in any scope in which
it could be defined, so this also supersedes DR44 and DR374 (the latter of
which we previously only implemented in C++11 mode onwards due to unclarity as
to whether it was a DR).

llvm-svn: 327705

6 years ago[ARM] Fix a check in vmov/vmvn immediate parsing
Mikhail Maltsev [Fri, 16 Mar 2018 12:46:49 +0000 (12:46 +0000)]
[ARM] Fix a check in vmov/vmvn immediate parsing

Summary:
Currently the check is incorrect and the following invalid
instruction is accepted and incorrectly assembled:

  vmov.i32        d2, #0x00a500a6

This patch fixes the issue.

Reviewers: olista01, rengolin

Reviewed By: rengolin

Subscribers: SjoerdMeijer, javed.absar, rogfer01, llvm-commits, kristof.beyls

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

llvm-svn: 327704

6 years ago[dotest] Clean up test folder clean-up
Pavel Labath [Fri, 16 Mar 2018 12:04:46 +0000 (12:04 +0000)]
[dotest] Clean up test folder clean-up

Summary:
This patch implements a unified way of cleaning the build folder of each
test. This is done by completely removing the build folder before each
test, in the respective setUp() method. Previously, we were using a
combination of several methods, each with it's own drawbacks:
- nuking the entire build tree before running dotest: the issue here is
  that this did not take place if you ran dotest manually
- running "make clean" before the main "make" target: this relied on the
  clean command being correctly implemented. This was usually true, but
  not always.
- for files which were not produced by make, each python file was
  responsible for ensuring their deleting, using a variety of methods.

With this approach, the previous methods become redundant. I remove the
first two, since they are centralized. For the other various bits of
clean-up code in python files, I indend to delete it when I come
across it.

Reviewers: aprantl

Subscribers: emaste, ki.stfu, mgorny, eraman, lldb-commits

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

llvm-svn: 327703

6 years ago[AArch64] Implement getArithmeticReductionCost
Matthew Simpson [Fri, 16 Mar 2018 11:34:15 +0000 (11:34 +0000)]
[AArch64] Implement getArithmeticReductionCost

This patch provides an implementation of getArithmeticReductionCost for
AArch64. We can specialize the cost of add reductions since they are computed
using the 'addv' instruction.

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

llvm-svn: 327702

6 years agoHashTableTest: squelch some "comparison of integers of different signs" warnings
Pavel Labath [Fri, 16 Mar 2018 10:30:26 +0000 (10:30 +0000)]
HashTableTest: squelch some "comparison of integers of different signs" warnings

llvm-svn: 327701

6 years agotsan: revert: Update buildgo.sh to pass -isysroot on Darwin.
Dmitry Vyukov [Fri, 16 Mar 2018 10:20:58 +0000 (10:20 +0000)]
tsan: revert: Update buildgo.sh to pass -isysroot on Darwin.

This commit breaks actual Go runtime build on gomote builders (10.12) with:

xcode-select: error: tool 'xcodebuild' requires Xcode,
but active developer directory '/Library/Developer/CommandLineTools'
is a command line tools instance

Without this part build works fine.
The original commit does not include any explanation as to why
it is needed.

llvm-svn: 327700

6 years agoDWARFVerifier: Enhance validation of .debug_names hash tables
Pavel Labath [Fri, 16 Mar 2018 10:02:16 +0000 (10:02 +0000)]
DWARFVerifier: Enhance validation of .debug_names hash tables

Summary:
This patch adds more checks to the .debug_names validator. Specifically,
they check for:
- buckets claiming to be non-empty but pointing to mismatched hashes
  (most consumers would interpret this as an empty bucket, but it
  questionable whether the generator meant that)
- hashes that are not reachable from any bucket
- names with incorrect hashes

Together, these checks ensure that any name in the index can be reached
through the hash table using the regular lookup algorithm. We also warn
if we encounter a name index without a hash table.

Reviewers: JDevlieghere, aprantl, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 327699

6 years ago[TTI, AArch64] Allow the cost model analysis to test vector reduce intrinsics
Matthew Simpson [Fri, 16 Mar 2018 10:00:30 +0000 (10:00 +0000)]
[TTI, AArch64] Allow the cost model analysis to test vector reduce intrinsics

This patch considers the experimental vector reduce intrinsics in the default
implementation of getIntrinsicInstrCost. The cost of these intrinsics is
computed with getArithmeticReductionCost and getMinMaxReductionCost. This patch
also adds a test case for AArch64 that indicates the costs we currently compute
for vector reduce intrinsics. These costs are inaccurate and will be updated in
a follow-on patch.

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

llvm-svn: 327698

6 years agoFreeBSD TSan support update
Vitaly Buka [Fri, 16 Mar 2018 08:23:33 +0000 (08:23 +0000)]
FreeBSD TSan support update

Summary:
- Disable thread_finalize callback on FreeBSD, fixing couple of unit tests.

Patch by David CARLIER

Reviewers: vitalybuka

Reviewed By: vitalybuka

Subscribers: emaste, kubamracek, krytarowski, llvm-commits, #sanitizers

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

llvm-svn: 327697

6 years agoMmap interceptor new option, Write Exec runtime detector
Vitaly Buka [Fri, 16 Mar 2018 08:22:18 +0000 (08:22 +0000)]
Mmap interceptor new option, Write Exec runtime detector

Summary: Following-up the refactoring of mmap interceptors, adding a new common option to detect PROT_WRITE|PROT_EXEC pages request.

Patch by David CARLIER

Reviewers: vitalybuka, vsk

Reviewed By: vitalybuka

Subscribers: krytarowski, #sanitizers

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

llvm-svn: 327696

6 years ago[ARM] FP16 codegen support for VSEL
Sjoerd Meijer [Fri, 16 Mar 2018 08:06:25 +0000 (08:06 +0000)]
[ARM] FP16 codegen support for VSEL

This implements lowering of SELECT_CC for f16s, which enables
codegen of VSEL with f16 types.

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

llvm-svn: 327695

6 years agoFix compilation warning introduced in r327654
Mikael Holmen [Fri, 16 Mar 2018 07:27:57 +0000 (07:27 +0000)]
Fix compilation warning introduced in r327654

The compiler complained about

../tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:184:15: error: unused variable 'CSI' [-Werror,-Wunused-variable]
    if (auto *CSI = CGF.CapturedStmtInfo) {
              ^
1 error generated.

I don't know this code but it seems like an easy fix so I push it anyway
to get rid of the warning.

llvm-svn: 327694

6 years ago[NFC] Void variables used for asserts only
Max Kazantsev [Fri, 16 Mar 2018 05:02:24 +0000 (05:02 +0000)]
[NFC] Void variables used for asserts only

llvm-svn: 327693

6 years agoSkip more lldb-mi tests which time out on Darwin
Vedant Kumar [Fri, 16 Mar 2018 04:11:03 +0000 (04:11 +0000)]
Skip more lldb-mi tests which time out on Darwin

Bot failure: https://ci.swift.org/job/oss-lldb-incremental-osx/1097/testReport/junit/TestMiTarget/MiTargetTestCase/test_lldbmi_target_attach_wait_for/

llvm-svn: 327692

6 years ago[cmake] Copy system debugserver from the right place when only CommandLineTools
Vedant Kumar [Fri, 16 Mar 2018 03:31:16 +0000 (03:31 +0000)]
[cmake] Copy system debugserver from the right place when only CommandLineTools
are installed

Instead of building debugserver when building lldb, I'd rather pass
LLDB_CODESIGN_IDENTITY="" to cmake and use the one already on my system.
However, on one of my machines I only have the CommandLineTools installed, and
so the hardcoded path to the system debugserver does not work for me.
Additionally, we should verify the LLDB framework exists on the machine before
trying to set the path to debugserver. This allows us to warn the user at
configure time that a system debugserver can't be found if they choose not to
build it themselves.

Patch by Alex Langford!

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

llvm-svn: 327691

6 years ago[demangler] Support for <template-param>s in generic lambdas.
Erik Pilkington [Fri, 16 Mar 2018 03:06:30 +0000 (03:06 +0000)]
[demangler] Support for <template-param>s in generic lambdas.

These <template-param>s refer to "artifical" <template-arg>s that don't appear
in the mangled name, so we just print them as "auto".

llvm-svn: 327690

6 years ago[InstCombine] add more tests for fcmp+select -> fabs; NFC
Sanjay Patel [Fri, 16 Mar 2018 01:06:33 +0000 (01:06 +0000)]
[InstCombine] add more tests for fcmp+select -> fabs; NFC

This should correspond to the patterns in D44091 and might
make handling these in the DAG unnecessary.

llvm-svn: 327689

6 years agoRevert r327248, "For most Targets the _GLOBAL_OFFSET_TABLE_ symbol is expected to...
Peter Collingbourne [Fri, 16 Mar 2018 01:01:44 +0000 (01:01 +0000)]
Revert r327248, "For most Targets the _GLOBAL_OFFSET_TABLE_ symbol is expected to be at"

This change broke ARM code that expects to be able to add
_GLOBAL_OFFSET_TABLE_ to the result of an R_ARM_REL32.

I will provide a reproducer on llvm-commits.

llvm-svn: 327688

6 years ago[Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; other...
Eugene Zelenko [Fri, 16 Mar 2018 00:37:51 +0000 (00:37 +0000)]
[Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 327687

6 years ago[X86][Btver2] Add support for multiple pipelines stages for x86 scalar schedules...
Simon Pilgrim [Thu, 15 Mar 2018 23:46:12 +0000 (23:46 +0000)]
[X86][Btver2] Add support for multiple pipelines stages for x86 scalar schedules. NFCI.

This allows us to use JWriteResIntPair for complex schedule classes (like WriteIDiv) as well as single pipe instructions.

llvm-svn: 327686

6 years ago[X86][Btver2] Tweak pipes test to remove register dependencies
Simon Pilgrim [Thu, 15 Mar 2018 23:15:11 +0000 (23:15 +0000)]
[X86][Btver2] Tweak pipes test to remove register dependencies

It gives us a better view of pipe usage in the timeline which is what the test is trying to show.

llvm-svn: 327685

6 years agoFix linker script operator precedence.
Rui Ueyama [Thu, 15 Mar 2018 23:12:33 +0000 (23:12 +0000)]
Fix linker script operator precedence.

"&" should have higher priority than "|" [1]. Previously, they had
the same priority.

[1] https://sourceware.org/binutils/docs/ld/Operators.html

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

llvm-svn: 327684

6 years ago[SelectionDAG][ARM][X86] Teach PromoteIntRes_SETCC to do a better job picking the...
Craig Topper [Thu, 15 Mar 2018 23:04:11 +0000 (23:04 +0000)]
[SelectionDAG][ARM][X86] Teach PromoteIntRes_SETCC to do a better job picking the result type for the setcc.

Previously if getSetccResultType returned an illegal type we just fell back to using the default promoted type. This appears to have been to handle the case where for vectors getSetccResultType returns the input type, but the input type itself isn't legal and will need to be promoted. Without the legality check we would never reach a legal type.

But just picking the promoted type to be the setcc type can create strange setccs where the result type is 128 bits and the operand type is 256 bits. If for example the result type was promoted to v8i16 from v8i1, but the input type was promoted from v8i23 to v8i32. We currently handle this with custom lowering code in X86.

This legality check also caused us reject the getSetccResultType when the input type needed to be widened or split. Even though that result wouldn't have caused legalization to get stuck.

This patch tries to fix this by detecting the getSetccResultType needs to be promoted. If its input type also needs to be promoted we'll try a ask for a new setcc result type based on its eventual promoted value. Otherwise we fall back to default type to promote to.

For any other illegal values we might get back from the initial call to getSetccResultType we just keep and allow it to be re-legalized later via splitting or widening or scalarizing.

llvm-svn: 327683

6 years ago[X86][Btver2] Fix ymm div/sqrt to use fmul unit
Simon Pilgrim [Thu, 15 Mar 2018 23:00:47 +0000 (23:00 +0000)]
[X86][Btver2] Fix ymm div/sqrt to use fmul unit

YMM FDiv/FSqrt are dispatched on pipe JFPU1 but should be performed on the JFPM unit - that is where most of the cycles are spent.

This matches the pipes for WriteFSqrt/WriteFDiv definitions.

llvm-svn: 327682

6 years agoUse standard `print(dbgs())` pattern to implement DebugLoc::dump
Sean Silva [Thu, 15 Mar 2018 22:51:55 +0000 (22:51 +0000)]
Use standard `print(dbgs())` pattern to implement DebugLoc::dump

The open-coded implementation had a bug. It didn't print filenames.

llvm-svn: 327681

6 years ago[InstCombine] add tests for fcmp+select -> fabs; NFC
Sanjay Patel [Thu, 15 Mar 2018 22:48:23 +0000 (22:48 +0000)]
[InstCombine] add tests for fcmp+select -> fabs; NFC

llvm-svn: 327680

6 years agoFix PDB injected sources test.
Zachary Turner [Thu, 15 Mar 2018 22:47:04 +0000 (22:47 +0000)]
Fix PDB injected sources test.

This test was originally disabled because it was failing on a bot.
It turns out I had run dos2unix on the file, and that removed a
necessary byte from the file.  I'm just recomitting the proper
file and updating the test to test a little bit more now.

llvm-svn: 327679

6 years agoMSan, FreeBSD few tests fixes
Vitaly Buka [Thu, 15 Mar 2018 22:41:28 +0000 (22:41 +0000)]
MSan, FreeBSD few tests fixes

Summary:
pthread_getattr_np_deadlock support
pthread_getname_np unsupported

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: eugenis, srhines, krytarowski, llvm-commits, #sanitizers

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

llvm-svn: 327678

6 years agoOpenBSD UBsan support procmaps
Vitaly Buka [Thu, 15 Mar 2018 22:40:47 +0000 (22:40 +0000)]
OpenBSD UBsan support procmaps

Summary: procmaps OpenBSD specifics

Patch by David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: mgorny, emaste, kubamracek, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 327677

6 years ago[X86][Btver2] Add test to show timeline of fpu instructions on different pipes/units
Simon Pilgrim [Thu, 15 Mar 2018 22:34:24 +0000 (22:34 +0000)]
[X86][Btver2] Add test to show timeline of fpu instructions on different pipes/units

Try to demonstrate the scheduling from fpu0/fpu1 pipes to the valu0/vimul/fpa or valu1/stc/fpm functional units

llvm-svn: 327676

6 years ago[PDB] Fix a bug where we were serializing hash tables incorrectly.
Zachary Turner [Thu, 15 Mar 2018 22:31:00 +0000 (22:31 +0000)]
[PDB] Fix a bug where we were serializing hash tables incorrectly.

There was some code that tried to calculate the number of 4-byte
words required to hold N bits, but it was instead computing the
number of bytes required to hold N bits.  This was leading to
extraneous data being output into the hash table, which would
cause certain operations in DIA (the Microsoft PDB reader) to
fail.

llvm-svn: 327675

6 years agoOpenBSD UBsan support common functions
Vitaly Buka [Thu, 15 Mar 2018 22:19:39 +0000 (22:19 +0000)]
OpenBSD UBsan support common functions

Summary: Ripped off OpenBSD specific from the common Linux implementation

Patch by David Carlier

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: emaste, srhines, kubamracek, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 327674

6 years ago[WebAssembly] Add DebugLoc information to WebAssembly block and loop.
Derek Schuff [Thu, 15 Mar 2018 22:06:51 +0000 (22:06 +0000)]
[WebAssembly] Add DebugLoc information to WebAssembly block and loop.

Patch by Yury Delendik
Differential Revision: https://reviews.llvm.org/D44448

llvm-svn: 327673

6 years ago[NVPTX] TblGen-ized lowering of WMMA intrinsics.
Artem Belevich [Thu, 15 Mar 2018 21:40:56 +0000 (21:40 +0000)]
[NVPTX] TblGen-ized lowering of WMMA intrinsics.

NFC.

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

llvm-svn: 327672

6 years ago[LoopUnroll] Peel off iterations if it makes conditions true/false.
Florian Hahn [Thu, 15 Mar 2018 21:34:43 +0000 (21:34 +0000)]
[LoopUnroll] Peel off iterations if it makes conditions true/false.

If the loop body contains conditions of the form IndVar < #constant, we
can remove the checks by peeling off #constant iterations.

This improves codegen for PR34364.

Reviewers: mkuper, mkazantsev, efriedma

Reviewed By: mkazantsev

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

llvm-svn: 327671

6 years agoRe-land r327620 "[CodeView] Initial support for emitting S_BLOCK32 symbols for lexica...
Reid Kleckner [Thu, 15 Mar 2018 21:24:04 +0000 (21:24 +0000)]
Re-land r327620 "[CodeView] Initial support for emitting S_BLOCK32 symbols for lexical scopes"

This is safe to land now that we don't copy FunctionInfo when rehashing
the DenseMap.

llvm-svn: 327670

6 years ago[codeview] Fix sense of the assertion about hashtable insertion
Reid Kleckner [Thu, 15 Mar 2018 21:18:42 +0000 (21:18 +0000)]
[codeview] Fix sense of the assertion about hashtable insertion

llvm-svn: 327669

6 years agoCOFF: Implement string tail merging.
Peter Collingbourne [Thu, 15 Mar 2018 21:14:02 +0000 (21:14 +0000)]
COFF: Implement string tail merging.

In COFF, duplicate string literals are merged by placing them in a
comdat whose leader symbol name contains a specific prefix followed
by the hash and partial contents of the string literal. This gives
us an easy way to identify sections containing string literals in
the linker: check for leader symbol names with the given prefix.

Any sections that are identified in this way as containing string
literals may be tail merged. We do so using the StringTableBuilder
class, which is also used to tail merge string literals in the ELF
linker. Tail merging is enabled only if ICF is enabled, as this
provides a signal as to whether the user cares about binary size.

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

llvm-svn: 327668

6 years agoCOFF: Move assignment of section RVAs to assignAddresses(). NFCI.
Peter Collingbourne [Thu, 15 Mar 2018 21:13:46 +0000 (21:13 +0000)]
COFF: Move assignment of section RVAs to assignAddresses(). NFCI.

This makes the design a little more similar to the ELF linker and
should allow for features such as ARM range extension thunks to be
implemented more easily.

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

llvm-svn: 327667

6 years agoFix structure alignment issue.
Zachary Turner [Thu, 15 Mar 2018 21:12:51 +0000 (21:12 +0000)]
Fix structure alignment issue.

llvm-svn: 327666

6 years ago[codeview] Delete FunctionInfo copy ctor and move out of DenseMap
Reid Kleckner [Thu, 15 Mar 2018 21:12:21 +0000 (21:12 +0000)]
[codeview] Delete FunctionInfo copy ctor and move out of DenseMap

We were unnecessarily copying a bunch of these FunctionInfo objects
around when rehashing the DenseMap.

Furthermore, r327620 introduced pointers referring to objects owned by
FunctionInfo, and the default copy ctor did the wrong thing in this
case, leading to use-after-free when the DenseMap gets rehashed.

I will rebase r327620 on this next and recommit it.

llvm-svn: 327665

6 years ago[LICM] Ignore exits provably not taken on first iteration when computing must execute
Philip Reames [Thu, 15 Mar 2018 21:04:28 +0000 (21:04 +0000)]
[LICM] Ignore exits provably not taken on first iteration when computing must execute

It is common to have conditional exits within a loop which are known not to be taken on some iterations, but not necessarily all. This patches extends our reasoning around guaranteed to execute (used when establishing whether it's safe to dereference a location from the preheader) to handle the case where an exit is known not to be taken on the first iteration and the instruction of interest *is* known to be taken on the first iteration.

This case comes up in two major ways:
* If we have a range check which we've been unable to eliminate, we frequently know that it doesn't fail on the first iteration.
* Pass ordering. We may have a check which will be eliminated through some sequence of other passes, but depending on the exact pass sequence we might never actually do so or we might miss other optimizations from passes run before the check is finally eliminated.

The initial version (here) is implemented via InstSimplify. At the moment, it catches a few cases, but misses a lot too. I added test cases for missing cases in InstSimplify which I'll follow up on separately. Longer term, we should probably wire SCEV through to here to get much smarter loop aware simplification of the first iteration predicate.

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

llvm-svn: 327664

6 years ago[AArch64] Adjust the cost model for Exynos M3
Evandro Menezes [Thu, 15 Mar 2018 20:37:32 +0000 (20:37 +0000)]
[AArch64] Adjust the cost model for Exynos M3

Fix typo.

llvm-svn: 327663

6 years ago[AArch64] Adjust the cost model for Exynos M3
Evandro Menezes [Thu, 15 Mar 2018 20:31:25 +0000 (20:31 +0000)]
[AArch64] Adjust the cost model for Exynos M3

Add special case for rotate right.

llvm-svn: 327662

6 years ago[AArch64] Adjust the cost model for Exynos M3
Evandro Menezes [Thu, 15 Mar 2018 20:31:13 +0000 (20:31 +0000)]
[AArch64] Adjust the cost model for Exynos M3

Increase the number of cheap as move cases of register reset.

llvm-svn: 327661

6 years ago[X86] Make sure we use FSUB instruction as the reference for operand order in isAddSu...
Craig Topper [Thu, 15 Mar 2018 20:30:54 +0000 (20:30 +0000)]
[X86] Make sure we use FSUB instruction as the reference for operand order in isAddSubOrSubAdd when recognizing subadd

The FADD part of the addsub/subadd pattern can have its operands commuted, but when checking for fsubadd we were using the fadd as reference and commuting the fsub node.

llvm-svn: 327660

6 years ago[X86] Add test case showing bad fmsubadd creation due to bad commuting.
Craig Topper [Thu, 15 Mar 2018 20:30:51 +0000 (20:30 +0000)]
[X86] Add test case showing bad fmsubadd creation due to bad commuting.

The code that creates fmsubadd from shuffle vector has some code to allow commuting the operands of the fadd node. This code was originally created when we only recognized fmaddsub. When fmsubadd support was added this code was not updated and is now commuting the fsub operands instead.

llvm-svn: 327659

6 years agoRemove empty file
David Blaikie [Thu, 15 Mar 2018 20:29:14 +0000 (20:29 +0000)]
Remove empty file

I should've deleted this in r320768 but accidentally just deleted its
contents instead.

llvm-svn: 327658

6 years agoRevert r327620 "[CodeView] Initial support for emitting S_BLOCK32 symbols for lexical...
Reid Kleckner [Thu, 15 Mar 2018 20:12:16 +0000 (20:12 +0000)]
Revert r327620 "[CodeView] Initial support for emitting S_BLOCK32 symbols for lexical scopes"

It is causing crashes when compiling Chrome in debug mode.

I'll try to debug it in a second.

llvm-svn: 327657

6 years ago[LV] Test commit. Removing white space.
Diego Caballero [Thu, 15 Mar 2018 19:34:27 +0000 (19:34 +0000)]
[LV] Test commit. Removing white space.

This is just to check that I have commit access privilege.

llvm-svn: 327656

6 years ago[EarlyCSE] Don't hide earler invariant.scopes
Philip Reames [Thu, 15 Mar 2018 18:12:27 +0000 (18:12 +0000)]
[EarlyCSE] Don't hide earler invariant.scopes

If we've already established an invariant scope with an earlier generation, we don't want to hide it in the scoped hash table with one with a later generation.  I noticed this when working on the invariant-load handling, but it also applies to the invariant.start case as well.

Without this change, my previous patch for invariant-load regresses some cases, so I'm pushing this without waiting for review.  This is why you don't make last minute tweaks to patches to catch "obvious cases" after it's already been reviewed.  Bad Philip!

llvm-svn: 327655

6 years ago[OPENMP, NVPTX] Improve globalization of the variables captured by value.
Alexey Bataev [Thu, 15 Mar 2018 18:10:54 +0000 (18:10 +0000)]
[OPENMP, NVPTX] Improve globalization of the variables captured by value.

If the variable is captured by value and the corresponding parameter in
the outlined function escapes its declaration context, this parameter
must be globalized. To globalize it we need to get the address of the
original parameter, load the value, store it to the global address and
use this global address instead of the original.

Patch improves globalization for parallel|teams regions + functions in
declare target regions.

llvm-svn: 327654

6 years agoMove some function declarations higher so they can be found.
Zachary Turner [Thu, 15 Mar 2018 17:56:44 +0000 (17:56 +0000)]
Move some function declarations higher so they can be found.

llvm-svn: 327653

6 years agoAdd missing #includes.
Zachary Turner [Thu, 15 Mar 2018 17:51:10 +0000 (17:51 +0000)]
Add missing #includes.

llvm-svn: 327652

6 years ago[PPC] Avoid non-simple MVT in STBRX optimization
Guozhi Wei [Thu, 15 Mar 2018 17:49:12 +0000 (17:49 +0000)]
[PPC] Avoid non-simple MVT in STBRX optimization

PR35402 triggered this case. It bswap and stores a 48bit value, current STBRX optimization transforms it into STBRX. Unfortunately 48bit is not a simple MVT, there is no PPC instruction to support it, and it can't be automatically expanded by llvm, so caused a crash.

This patch detects the non-simple MVT and returns early.

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

llvm-svn: 327651

6 years ago[X86][Btver2] Attach AES/CLMUL instructions to a scheduler pipe
Simon Pilgrim [Thu, 15 Mar 2018 17:45:10 +0000 (17:45 +0000)]
[X86][Btver2] Attach AES/CLMUL instructions to a scheduler pipe

llvm-svn: 327650

6 years ago[X86] Simplify the type legality checking for (FM)ADDSUB/SUBADD matching. NFCI
Craig Topper [Thu, 15 Mar 2018 17:38:59 +0000 (17:38 +0000)]
[X86] Simplify the type legality checking for (FM)ADDSUB/SUBADD matching. NFCI

Rather than enumerating all specific types, for the DAG combine we can just use TLI::isTypeLegal and an SSE3 check. For the BUILD_VECTOR version we already know the type is legal so we just need to check SSE3.

llvm-svn: 327649

6 years ago[X86] Fix 80 column violations.
Craig Topper [Thu, 15 Mar 2018 17:38:55 +0000 (17:38 +0000)]
[X86] Fix 80 column violations.

llvm-svn: 327648

6 years agoRefactor the PDB HashTable class.
Zachary Turner [Thu, 15 Mar 2018 17:38:26 +0000 (17:38 +0000)]
Refactor the PDB HashTable class.

It previously only worked when the key and value types were
both 4 byte integers.  We now have a use case for a non trivial
value type, so we need to extend it to support arbitrary value
types, which means templatizing it.

llvm-svn: 327647

6 years ago[EarlyCSE] Reuse invariant scopes for invariant load
Philip Reames [Thu, 15 Mar 2018 17:29:32 +0000 (17:29 +0000)]
[EarlyCSE] Reuse invariant scopes for invariant load

This is a follow up to https://reviews.llvm.org/D43716 which rewrites the invariant load handling using the new infrastructure. It's slightly more powerful, but only in somewhat minor ways for the moment. It's not clear that DSE of stores to invariant locations is actually interesting since why would your IR have such a construct to start with?

Note: The submitted version is slightly different than the reviewed one.  I realized the scope could start for an invariant load which was proven redundant and removed.  Added a test case to illustrate that as well.

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

llvm-svn: 327646

6 years agoAdd a comment about ELF spec and the symbol table's sh_info.
Rui Ueyama [Thu, 15 Mar 2018 17:10:50 +0000 (17:10 +0000)]
Add a comment about ELF spec and the symbol table's sh_info.

llvm-svn: 327645

6 years agoSplit skipIf decorator, the condition is supposed to be OR
Adrian Prantl [Thu, 15 Mar 2018 17:07:05 +0000 (17:07 +0000)]
Split skipIf decorator, the condition is supposed to be OR

llvm-svn: 327644

6 years ago[dotest] remove confirm_directory_exclusivity remnants
Pavel Labath [Thu, 15 Mar 2018 16:52:37 +0000 (16:52 +0000)]
[dotest] remove confirm_directory_exclusivity remnants

llvm-svn: 327643

6 years ago[InstSimplify] peek through unsigned FP casts for sign-bit compares (PR36682)
Roman Lebedev [Thu, 15 Mar 2018 16:17:46 +0000 (16:17 +0000)]
[InstSimplify] peek through unsigned FP casts for sign-bit compares (PR36682)

This pattern came up in PR36682 / D44390
https://bugs.llvm.org/show_bug.cgi?id=36682
https://reviews.llvm.org/D44390
https://godbolt.org/g/oKvT5H

See also D44421, D44424

Reviewers: spatel, majnemer, efriedma, arsenm

Reviewed By: spatel

Subscribers: wdng, llvm-commits

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

llvm-svn: 327642

6 years ago[InstSimplify][NFC] simplifyICmpWithConstant(): refactor GetCompareTy() calls
Roman Lebedev [Thu, 15 Mar 2018 16:17:40 +0000 (16:17 +0000)]
[InstSimplify][NFC] simplifyICmpWithConstant(): refactor GetCompareTy() calls

Preparation for D44425.

llvm-svn: 327641

6 years ago[llvm-mca] Simplify code. NFC.
Andrea Di Biagio [Thu, 15 Mar 2018 16:13:12 +0000 (16:13 +0000)]
[llvm-mca] Simplify code. NFC.

Now both method DispatchUnit::checkRAT() and DispatchUnit::canDispatch take as
input an Instruction refrence instead of an instruction descriptor.
This was requested by Simon in D44488 to simplify the diff.

llvm-svn: 327640

6 years ago[OpenMP][libomptarget] Enable usage of shared memory slots
Gheorghe-Teodor Bercea [Thu, 15 Mar 2018 16:05:34 +0000 (16:05 +0000)]
[OpenMP][libomptarget] Enable usage of shared memory slots

Summary:
Allow the runtime to use the existing shared memory statically allocated slots.

When a variable is globalized, the underlying memory can be either shared or global memory (both have block-wide visibility). In this case, we allow that the storage to use a limited amount of shared memory that has been statically allocated already. Only if shared memory doesn't prove to be enough do we then invoke malloc() to create a new global memory slot.

Reviewers: ABataev, carlo.bertolli, grokos, caomhin

Reviewed By: grokos

Subscribers: guansong, openmp-commits

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

llvm-svn: 327639

6 years ago[ConstantFolding, InstSimplify] Handle more vector GEPs
Matthew Simpson [Thu, 15 Mar 2018 16:00:29 +0000 (16:00 +0000)]
[ConstantFolding, InstSimplify] Handle more vector GEPs

This patch addresses some additional cases where the compiler crashes upon
encountering vector GEPs. This should fix PR36116.

Differential Revision: https://reviews.llvm.org/D44219
Reference: https://bugs.llvm.org/show_bug.cgi?id=36116

llvm-svn: 327638

6 years ago[OpenMP][libomptarget] Enable multiple frames per global memory slot
Gheorghe-Teodor Bercea [Thu, 15 Mar 2018 15:56:04 +0000 (15:56 +0000)]
[OpenMP][libomptarget] Enable multiple frames per global memory slot

Summary: To save on calls to malloc, this patch enables the re-use of pre-allocated global memory slots.

Reviewers: ABataev, grokos, carlo.bertolli, caomhin

Reviewed By: grokos

Subscribers: guansong, openmp-commits

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

llvm-svn: 327637

6 years ago[OPENMP] Codegen for `omp declare target` construct.
Alexey Bataev [Thu, 15 Mar 2018 15:47:20 +0000 (15:47 +0000)]
[OPENMP] Codegen for `omp declare target` construct.

Added initial codegen for device side of declarations inside `omp
declare target` construct + codegen for implicit `declare target`
functions, which are used in the target regions.

llvm-svn: 327636

6 years ago[PowerPC] Optimize TLS initial-exec sequence to use X-Form loads/stores
Zaara Syeda [Thu, 15 Mar 2018 15:34:41 +0000 (15:34 +0000)]
[PowerPC] Optimize TLS initial-exec sequence to use X-Form loads/stores

This patch adds new load/store instructions for integer scalar types
which can be used for X-Form when fed by add with an @tls relocation.

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

llvm-svn: 327635

6 years agoRecommit r326946 after reducing CallArgList memory footprint
Yaxun Liu [Thu, 15 Mar 2018 15:25:19 +0000 (15:25 +0000)]
Recommit r326946 after reducing CallArgList memory footprint

llvm-svn: 327634

6 years agoFix TestProcessLaunch breakage on MacOS
Pavel Labath [Thu, 15 Mar 2018 15:21:54 +0000 (15:21 +0000)]
Fix TestProcessLaunch breakage on MacOS

This test started failing after r327625. The cause seems difference in the
treatment of relative --stdin paths between MacOS (debugserver?) and linux
(lldb-server?). Linux treats this as relative to the debuggers PWD, while MacOS
as relative to (I think) the future PWD of the launched process.

This fixes the issue by using absolute paths, which should work everywhere, but
we should probably unify this path handling as well. I'll ask around about what
is the expected behavior here.

llvm-svn: 327633

6 years ago[X86][Btver2] Remove JAny resource, and map system/microcoded instructions to JALU...
Simon Pilgrim [Thu, 15 Mar 2018 15:12:12 +0000 (15:12 +0000)]
[X86][Btver2] Remove JAny resource, and map system/microcoded instructions to JALU pipes

Simplifies throughput to the issue width (1/2) instead of permitting any pipe (1/6)

llvm-svn: 327632

6 years ago[InstSimplify] add tests with NaN operand for fp binops; NFC
Sanjay Patel [Thu, 15 Mar 2018 14:48:39 +0000 (14:48 +0000)]
[InstSimplify] add tests with NaN operand for fp binops; NFC

llvm-svn: 327631

6 years ago[X86][SSE] Introduce Float/Vector WriteMove, WriteLoad and Writetore scheduler classes
Simon Pilgrim [Thu, 15 Mar 2018 14:45:30 +0000 (14:45 +0000)]
[X86][SSE] Introduce Float/Vector WriteMove, WriteLoad and Writetore scheduler classes

As discussed on D44428 and PR36726, this patch splits off WriteFMove/WriteVecMove, WriteFLoad/WriteVecLoad and WriteFStore/WriteVecStore scheduler classes to permit vectors to be handled separately from gpr/scalar types.

I've minimised the diff here by only moving various basic SSE/AVX vector instructions across - we can fix the rest when called for. This does fix the MOVDQA vs MOVAPS/MOVAPD discrepancies mentioned on D44428.

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

llvm-svn: 327630