OSDN Git Service

android-x86/external-llvm.git
6 years ago[DWARF] Fixing a bug in DWARF v5 string offsets tables where the length encoded the...
Wolfgang Pieb [Thu, 10 May 2018 20:02:34 +0000 (20:02 +0000)]
[DWARF] Fixing a bug in DWARF v5 string offsets tables where the length encoded the contribution
length excluding the table header. Instead it must encode the contribution length minus the length
field itself.

Reviewer: JDevliegehere

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332030 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Moving overflow computation logic from InstCombine to ValueTracking...
Omer Paparo Bivas [Thu, 10 May 2018 19:46:19 +0000 (19:46 +0000)]
[InstCombine] Moving overflow computation logic from InstCombine to ValueTracking; NFC

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

Change-Id: Ifabcbe431a2169743b3cc310f2a34fd706f13f02

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332026 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] add minnum/maxnum tests (PR37404, PR37405); NFC
Sanjay Patel [Thu, 10 May 2018 19:21:08 +0000 (19:21 +0000)]
[InstCombine] add minnum/maxnum tests (PR37404, PR37405); NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332025 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Initialize HasPTWRITE member of X86Subtarget
Gabor Buella [Thu, 10 May 2018 19:15:10 +0000 (19:15 +0000)]
[X86] Initialize HasPTWRITE member of X86Subtarget

This was missing from r331961.
Caught by sanitizer bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332024 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Convert/Merge more instregex patterns to reduce InstrRW compile time.
Simon Pilgrim [Thu, 10 May 2018 19:08:06 +0000 (19:08 +0000)]
[X86] Convert/Merge more instregex patterns to reduce InstrRW compile time.

Use instrs lists or merge multiple instregex patterns.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332022 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd regression test for r331976
George Burgess IV [Thu, 10 May 2018 18:37:54 +0000 (18:37 +0000)]
Add regression test for r331976

In general, it's difficult to poke the ConstantExpr code in CFLAA, since
LLVM is so great at eagerly reducing ConstantExprs. :)

Sadly, this only shows a functional difference from before the patch
because CFLAA has some special logic around taking loads of non-pointers
into account. Namely, with the broken select behavior, CFLAA will
completely fail to take note of @g3. Since CFLAA doesn't have any record
about @g3 when we do an alias query for @g3 and %a, it conservatively
answers MayAlias. When we properly take @g3 into account with the new
select logic, we get NoAlias for this query.

I suspect that the aforementioned "special logic" isn't completely
correct, but this test-case should prevent future wonky aliasing results
from appearing for these flavors of ConstantExprs, so I think it's still
worth having.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332017 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CGP] Split large data structres to sink more GEPs
Haicheng Wu [Thu, 10 May 2018 18:27:36 +0000 (18:27 +0000)]
[CGP] Split large data structres to sink more GEPs

Accessing the members of a large data structures needs a lot of GEPs which
usually have large offsets due to the size of the underlying data structure. If
the offsets are too large to fit into the r+i addressing mode, these GEPs cannot
be sunk to their users' blocks and many extra registers are needed then to carry
the values of these GEPs.

This patch tries to split a large data struct starting from %base like the
following.

Before:
BB0:
  %base     =

BB1:
  %gep0     = gep %base, off0
  %gep1     = gep %base, off1
  %gep2     = gep %base, off2

BB2:
  %load1    = load %gep0
  %load2    = load %gep1
  %load3    = load %gep2

After:
BB0:
  %base     =
  %new_base = gep %base, off0

BB1:
  %new_gep0 = %new_base
  %new_gep1 = gep %new_base, off1 - off0
  %new_gep2 = gep %new_base, off2 - off0

BB2:
  %load1    = load i32, i32* %new_gep0
  %load2    = load i32, i32* %new_gep1
  %load3    = load i32, i32* %new_gep2

In the above example, the struct is split into two parts. The first part still
starts from %base and the second part starts from %new_base. After the
splitting, %new_gep1 and %new_gep2 have smaller offsets and then can be sunk to
BB2 and folded into their users.

The algorithm to split data structure is simple and very similar to the work of
merging SExts. First, it collects GEPs that have large offsets when iterating
the blocks. Second, it splits the underlying data structures and updates the
collected GEPs to use smaller offsets.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332015 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[LLVM-C] Add Accessors for Common DIType and DILocation Properties
Robert Widmann [Thu, 10 May 2018 18:23:55 +0000 (18:23 +0000)]
[LLVM-C] Add Accessors for Common DIType and DILocation Properties

Summary:
- Adds getters for the line, column, and scope of a DILocation
- Adds getters for the name, size in bits, offset in bits, alignment in bits, line, and flags of a DIType

Reviewers: whitequark, harlanhaskins, deadalnix

Reviewed By: whitequark

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332014 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[LLVM-C] Move DIBuilder Bindings For Temporary MDNodes
Robert Widmann [Thu, 10 May 2018 18:09:53 +0000 (18:09 +0000)]
[LLVM-C] Move DIBuilder Bindings For Temporary MDNodes

Summary: Move LLVMTemporaryMDNode and LLVMMetadataReplaceAllUsesWith to the C bindings and add LLVMDeleteTemporaryMDNode for deleting non-RAUW'ed temporary nodes.

Reviewers: whitequark, harlanhaskins, deadalnix

Reviewed By: whitequark

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332010 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WebAsembly] Update default triple in test files to wasm32-unknown-unkown.
Sam Clegg [Thu, 10 May 2018 17:49:11 +0000 (17:49 +0000)]
[WebAsembly] Update default triple in test files to wasm32-unknown-unkown.

Summary: The final -wasm component has been the default for some time now.

Subscribers: jfb, dschuff, jgravelle-google, eraman, aheejin, JDevlieghere, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332007 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86][Znver1] Remove unnecessary SchedWritePMULLD InstRW overrides.
Simon Pilgrim [Thu, 10 May 2018 17:42:26 +0000 (17:42 +0000)]
[X86][Znver1] Remove unnecessary SchedWritePMULLD InstRW overrides.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332006 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WebAssembly] Create section start symbols automatically for all sections
Sam Clegg [Thu, 10 May 2018 17:38:35 +0000 (17:38 +0000)]
[WebAssembly] Create section start symbols automatically for all sections

These symbols only get included in the output symbols table if
they are used in a relocation.

This behaviour matches more closely the ELF object writer.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332005 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[PM/LoopUnswitch] Avoid pointlessly creating an exit block set.
Chandler Carruth [Thu, 10 May 2018 17:33:20 +0000 (17:33 +0000)]
[PM/LoopUnswitch] Avoid pointlessly creating an exit block set.

This code can just test whether blocks are *in* the loop, which we
already have a dedicated set tracking in the loop itself.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332004 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86][SNB] Fix typo in PEXTRDmr instregex, was missing VPEXTRDmr.
Simon Pilgrim [Thu, 10 May 2018 17:30:49 +0000 (17:30 +0000)]
[X86][SNB] Fix typo in PEXTRDmr instregex, was missing VPEXTRDmr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332002 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Split WriteVecALU/WriteVecLogic/WriteShuffle/WriteVarShuffle/WritePSADBW/WriteP...
Simon Pilgrim [Thu, 10 May 2018 17:06:09 +0000 (17:06 +0000)]
[X86] Split WriteVecALU/WriteVecLogic/WriteShuffle/WriteVarShuffle/WritePSADBW/WritePHAdd scheduler classes

Split off XMM classes from the default (MMX) classes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331999 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] regenerate full checks; NFC
Sanjay Patel [Thu, 10 May 2018 17:05:38 +0000 (17:05 +0000)]
[InstCombine] regenerate full checks; NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331998 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[mips] Accept 32-bit offsets for ld/sd/lld commands
Simon Atanasyan [Thu, 10 May 2018 16:01:36 +0000 (16:01 +0000)]
[mips] Accept 32-bit offsets for ld/sd/lld commands

This is a follow up to the rL330983. The patch teaches ld, sd, and lld
commands accept 32-bit memory offsets by replacing `mem_simm16` operand
to `mem_simmptr`. In fact, these commands should accept 64-bit offsets,
but so large offsets require another command expanding and will be
supported by a separate patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331997 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[mips] Accept 32-bit offsets for lh and lhu commands
Simon Atanasyan [Thu, 10 May 2018 16:01:18 +0000 (16:01 +0000)]
[mips] Accept 32-bit offsets for lh and lhu commands

This is a follow up to the rL330983. The patch teaches lh and lhu
commands accepts 32-bit memory offsets by replacing `mem_simm16` operand
to `mem_simmptr`.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331996 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[llvm-objcopy] Add tests for help messages
Alexander Shaposhnikov [Thu, 10 May 2018 15:56:04 +0000 (15:56 +0000)]
[llvm-objcopy] Add tests for help messages

This diff slightly reorganizes the tests  and improves
the test coverage of help messages / error reports.

Test plan: make check-all

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331993 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[x86] fix fmaxnum/fminnum with nnan
Sanjay Patel [Thu, 10 May 2018 15:40:49 +0000 (15:40 +0000)]
[x86] fix fmaxnum/fminnum with nnan

With nnan, there's no need for the masked merge / blend
sequence (that probably costs much more than the min/max
instruction).

Somewhere between clang 5.0 and 6.0, we started producing
these intrinsics for fmax()/fmin() in C source instead of
libcalls or fcmp/select. The backend wasn't prepared for
that, so we regressed perf in those cases.

Note: it's possible that other targets have similar problems
as seen here.

Noticed while investigating PR37403 and related bugs:
https://bugs.llvm.org/show_bug.cgi?id=37403

The IR FMF propagation cases still don't work. There's
a proposal that might fix those cases in D46563.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331992 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DSE] Teach the pass about partial overwrite of atomic memory intrinsics
Daniel Neilson [Thu, 10 May 2018 15:12:49 +0000 (15:12 +0000)]
[DSE] Teach the pass about partial overwrite of atomic memory intrinsics

Summary:
This change teaches DSE that the atomic memory intrinsics can be overwriten
partially in the same way as the non-atomic forms. Specifically, that the
atomic memcpy & memset can be shortened at the end and that the atomic memset
can be shortened at the beginning, if they partially overwritten
by later stores.

Reviewers: mkazantsev, skatkov, apilipenko, efriedma, rsmith, spatel, filcab, sanjoy

Reviewed By: efriedma

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331991 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[PR37339] Fix assertion in FunctionComparator::cmpInlineAsm
whitequark [Thu, 10 May 2018 15:05:47 +0000 (15:05 +0000)]
[PR37339] Fix assertion in FunctionComparator::cmpInlineAsm

Fixes bug https://bugs.llvm.org/show_bug.cgi?id=37339.

InlineAsm is only uniqued if the FunctionTypes are exactly the
same, while cmpTypes() for example considers all pointer types
in the default address space to be the same. For this reason
the end of cmpInlineAsm() can be reached.

This patch replaces the unreachable assertion with a check that
the function types are not identical.

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

Reviewers: jfb

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331990 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[x86] fix test names; NFC
Sanjay Patel [Thu, 10 May 2018 14:58:47 +0000 (14:58 +0000)]
[x86] fix test names; NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331989 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[x86] add tests for maxnum/minnum intrinsics with nnan; NFC
Sanjay Patel [Thu, 10 May 2018 14:48:42 +0000 (14:48 +0000)]
[x86] add tests for maxnum/minnum intrinsics with nnan; NFC

Clang 6.0 was updated to create these intrinsics rather than
libcalls or fcmp/select, but the backend wasn't prepared to
handle that optimally.

This bug is not the primary reason for PR37403:
https://bugs.llvm.org/show_bug.cgi?id=37403
...but it's probably more important for x86 perf.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331988 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDon't redefine a bunch of defines from llvm-config.h in config.h.
Nico Weber [Thu, 10 May 2018 14:45:05 +0000 (14:45 +0000)]
Don't redefine a bunch of defines from llvm-config.h in config.h.

r210144 made config.h include llvm-config.h and deduplicated defines. Then
rL239987 later added back some of the duplication.
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150914/300329.html
suggests this was done for the configure/make build, which no longer exists.

No intended behavior change.

https://reviews.llvm.org/D46288

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331987 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DWARF] Remove unused member and fix(?) the unit-tests on big endian hosts
James Henderson [Thu, 10 May 2018 14:36:24 +0000 (14:36 +0000)]
[DWARF] Remove unused member and fix(?) the unit-tests on big endian hosts

I can't verified the fix on a big endian host, so I'm not 100% certain it
will work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331986 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DAG] Avoid using deleted node in rebuildSetCC
Nirav Dave [Thu, 10 May 2018 14:28:54 +0000 (14:28 +0000)]
[DAG] Avoid using deleted node in rebuildSetCC

Summary:
The combine in rebuildSetCC may be combined to another
node leaving our references stale. Keep a handle on
it to avoid stale references.

Fixes PR36602.

Reviewers: dbabokin, RKSimon, eli.friedman, davide

Subscribers: hiraditya, uabelho, JesperAntonsson, qcolombet, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331985 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DWARF] DwarfGenerator.h LineTable: explicitly mark DG as unused
Roman Lebedev [Thu, 10 May 2018 14:16:45 +0000 (14:16 +0000)]
[DWARF] DwarfGenerator.h LineTable: explicitly mark DG as unused

Just want to unbreak the build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331984 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DWARF] dwarfgen::LineTable::writeData(): pacify -Wcovered-switch-default
Roman Lebedev [Thu, 10 May 2018 14:16:41 +0000 (14:16 +0000)]
[DWARF] dwarfgen::LineTable::writeData(): pacify -Wcovered-switch-default

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331983 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DWARF] DWARFDebugLineTest: fix a few more signed/unsigned mismatch warnings
Roman Lebedev [Thu, 10 May 2018 14:16:37 +0000 (14:16 +0000)]
[DWARF] DWARFDebugLineTest: fix a few more signed/unsigned mismatch warnings

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331982 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix signed/unsigned comparison warning and print format
James Henderson [Thu, 10 May 2018 12:15:43 +0000 (12:15 +0000)]
Fix signed/unsigned comparison warning and print format

The print format was causing at least 2 unit-test failures from r331971.

The signed/unsigned comparison warnings only appeared to affect two lines but
it was unclear whether it might just pop up on other lines, so I have been
explicit in all the literals in the tests.

There were other bot unit-test failures that I am still investigating.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331978 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CFLGraph] Fixed Select instruction handling
David Bolvansky [Thu, 10 May 2018 11:47:36 +0000 (11:47 +0000)]
[CFLGraph] Fixed Select instruction handling

Summary:
Operand 0 is the condition, not the true value.

Use op 1 and op 2 as the correct values.

Reviewers: george.burgess.iv, nlopes, efriedma

Reviewed By: george.burgess.iv

Subscribers: craig.topper, rjmccall, lebedev.ri, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331976 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Only propagate known leading zeros from udiv input to output.
Benjamin Kramer [Thu, 10 May 2018 11:45:18 +0000 (11:45 +0000)]
[InstCombine] Only propagate known leading zeros from udiv input to output.

Put in a conservatively correct estimate for now. Avoids miscompiling
clang in FDO mode. This is really tricky to trigger in reality as
basically all interesting cases will be folded away by computeKnownBits
earlier, I was unable to find a reasonably small test case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331975 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DWARF] Rework debug line parsing to use llvm::Error and callbacks
James Henderson [Thu, 10 May 2018 10:51:33 +0000 (10:51 +0000)]
[DWARF] Rework debug line parsing to use llvm::Error and callbacks

Reviewed by: dblaikie, JDevlieghere, espindola

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

Summary:
The .debug_line parser previously reported errors by printing to stderr and
return false. This is not particularly helpful for clients of the library code,
as it prevents them from handling the errors in a manner based on the calling
context. This change switches to using llvm::Error and callbacks to indicate
what problems were detected during parsing, and has updated clients to handle
the errors in a location-specific manner. In general, this means that they
continue to do the same thing to external users. Below, I have outlined what
the known behaviour changes are, relating to this change.

There are two levels of "errors" in the new error mechanism, to broadly
distinguish between different fail states of the parser, since not every
failure will prevent parsing of the unit, or of subsequent unit. Malformed
table errors that prevent reading the remainder of the table (reported by
returning them) and other minor issues representing problems with parsing that
do not prevent attempting to continue reading the table (reported by calling a
specified callback funciton). The only example of this currently is when the
last sequence of a unit is unterminated. However, I think it would be good to
change the handling of unrecognised opcodes to report as minor issues as well,
rather than just printing to the stream if --verbose is used (this would be a
subsequent change however).

I have substantially extended the DwarfGenerator to be able to handle
custom-crafted .debug_line sections, allowing for comprehensive unit-testing
of the parser code. For now, I am just adding unit tests to cover the basic
error reporting, and positive cases, and do not currently intend to test every
part of the parser, although the framework should be sufficient to do so at a
later point.

Known behaviour changes:
  - The dump function in DWARFContext now does not attempt to read subsequent
  tables when searching for a specific offset, if the unit length field of a
  table before the specified offset is a reserved value.
  - getOrParseLineTable now returns a useful Error if an invalid offset is
  encountered, rather than simply a nullptr.
  - The parse functions no longer use `WithColor::warning` directly to report
  errors, allowing LLD to call its own warning function.
  - The existing parse error messages have been updated to not specifically
  include "warning" in their message, allowing consumers to determine what
  severity the problem is.
  - If the line table version field appears to have a value less than 2, an
  informative error is returned, instead of just false.
  - If the line table unit length field uses a reserved value, an informative
  error is returned, instead of just false.
  - Dumping of .debug_line.dwo sections is now implemented the same as regular
  .debug_line sections.
  - Verbose dumping of .debug_line[.dwo] sections now prints the prologue, if
  there is a prologue error, just like non-verbose dumping.

As a helper for the generator code, I have re-added emitInt64 to the
AsmPrinter code. This previously existed, but was removed way back in r100296,
presumably because it was dead at the time.

This change also requires a change to LLD, which will be committed separately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331971 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[mips] Correct the predicates of cvt.fmt.fmt instructions
Simon Dardis [Thu, 10 May 2018 10:42:30 +0000 (10:42 +0000)]
[mips] Correct the predicates of cvt.fmt.fmt instructions

Reviewers: atanasyan, smaksimovic, abeserminji

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331969 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] ptwrite intrinsic
Gabor Buella [Thu, 10 May 2018 07:26:05 +0000 (07:26 +0000)]
[X86] ptwrite intrinsic

Reviewers: craig.topper, RKSimon

Reviewed By: craig.topper, RKSimon

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331961 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix tests added in r331924 so that they work on Windows.
Douglas Yung [Thu, 10 May 2018 03:06:42 +0000 (03:06 +0000)]
Fix tests added in r331924 so that they work on Windows.

The test needed to check for the optional executable extension (llvm-objcopy.EXE).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331952 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SCEV] Add missed Test for rL331949.
Serguei Katkov [Thu, 10 May 2018 01:42:59 +0000 (01:42 +0000)]
[SCEV] Add missed Test for rL331949.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331950 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSCEV] Do not use induction in isKnownPredicate for simplification umax.
Serguei Katkov [Thu, 10 May 2018 01:40:43 +0000 (01:40 +0000)]
SCEV] Do not use induction in isKnownPredicate for simplification umax.

During simplification umax we trigger isKnownPredicate twice. As a first attempt it
tries the induction. To do that it tries to get post increment of SCEV.
Re-writing the SCEV may result in simplification of umax. If the SCEV contains a lot
of umax operations this recursion becomes very slow.

The added test demonstrates the slow behavior.

To resolve this we use only simple ways to check whether the predicate is known.

Reviewers: sanjoy, mkazantsev
Reviewed By: sanjoy
Subscribers: lebedev.ri, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46046

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331949 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Reorder an if condition to put a cheap check in front of a computeKnown...
Craig Topper [Thu, 10 May 2018 00:53:25 +0000 (00:53 +0000)]
[InstCombine] Reorder an if condition to put a cheap check in front of a computeKnownBits call. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331948 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Use APInt::getBitsSetFrom to shortern a line and fix an 80 columns...
Craig Topper [Thu, 10 May 2018 00:53:22 +0000 (00:53 +0000)]
[InstCombine] Use APInt::getBitsSetFrom to shortern a line and fix an 80 columns violation. NFC

Fix a similar line in the same function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331947 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[LIT] Add the missing file
Chris Matthews [Thu, 10 May 2018 00:08:39 +0000 (00:08 +0000)]
[LIT] Add the missing file

I forgot to commit this file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331946 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRefactor test incase results are backwards
Chris Matthews [Thu, 10 May 2018 00:06:17 +0000 (00:06 +0000)]
Refactor test incase results are backwards

Looks like results can come in either way in this file.  Loosen the ordering constraints.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331945 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Inscombine] fix a signedness warning which broke -Werror builds
Philip Reames [Thu, 10 May 2018 00:05:29 +0000 (00:05 +0000)]
[Inscombine] fix a signedness warning which broke -Werror builds

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331944 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[LIT] Handle xml characters in test names
Chris Matthews [Wed, 9 May 2018 23:48:32 +0000 (23:48 +0000)]
[LIT] Handle xml characters in test names

Lit creates malformed xml when the test case has an & in the name.

Escape those correctly.

This also adds a test case which I will add other nasty encoding issues to in some followup commits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331942 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NVPTX] Added a feature to use short pointers for const/local/shared AS.
Artem Belevich [Wed, 9 May 2018 23:46:19 +0000 (23:46 +0000)]
[NVPTX] Added a feature to use short pointers for const/local/shared AS.

Const/local/shared address spaces are all < 4GB and we can always use
32-bit pointers to access them. This has substantial performance impact
on kernels that uses shared memory for intermediary results.

The feature is disabled by default.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331941 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[PhaseOrdering] remove stale comments; NFC
Sanjay Patel [Wed, 9 May 2018 23:10:46 +0000 (23:10 +0000)]
[PhaseOrdering] remove stale comments; NFC

Forgot to update this with rL331937.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331939 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AggressiveInstCombine] convert a chain of 'and-shift' bits into masked compare
Sanjay Patel [Wed, 9 May 2018 23:08:15 +0000 (23:08 +0000)]
[AggressiveInstCombine] convert a chain of 'and-shift' bits into masked compare

This is a follow-up to D45986. As suggested there, we should match the "all-bits-set"
pattern in addition to "any-bits-set".

This was a little more complicated than I thought it would be initially because the
"and 1" instruction can be anywhere in the chain. Hopefully, the code comments make
that logic understandable, but if you see a way to simplify or improve that, it's
most appreciated.

This transforms patterns that emerge from bitfield tests as seen in PR37098:
https://bugs.llvm.org/show_bug.cgi?id=37098

I think it would also help reduce the large test from:
D46336
D46595
but we need something to reassociate that case to the forms we're expecting here first.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331937 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Widen guards with conditions between
Philip Reames [Wed, 9 May 2018 22:56:32 +0000 (22:56 +0000)]
[InstCombine] Widen guards with conditions between

The previous handling for guard widening in InstCombine was extremely restrictive. In particular, it didn't handle the common case where we had two guards separated by a single icmp. Handle this by scanning through a small fixed window of instructions to find the next guard if needed.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331935 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Teach SimplifyDemandedBits that udiv doesn't demand low dividend bits...
Benjamin Kramer [Wed, 9 May 2018 22:27:34 +0000 (22:27 +0000)]
[InstCombine] Teach SimplifyDemandedBits that udiv doesn't demand low dividend bits that are zero in the divisor

This is safe as long as the udiv is not exact. The pattern is not common in
C++ code, but comes up all the time in code generated by XLA's GPU backend.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331933 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ARM] Add support for SETCCCARRY instead of SETCCE
Amaury Sechet [Wed, 9 May 2018 22:15:51 +0000 (22:15 +0000)]
[ARM] Add support for SETCCCARRY instead of SETCCE

Summary: As per title. SETCCE is deprecated and will eventually be removed.

Reviewers: rogfer01, efriedma, rengolin, javed.absar

Subscribers: kristof.beyls, chrib, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331929 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[GlobalISel][Legalizer] Widening the second src op of shifts bug fix
Roman Tereshin [Wed, 9 May 2018 21:43:30 +0000 (21:43 +0000)]
[GlobalISel][Legalizer] Widening the second src op of shifts bug fix

The second source operand of G_SHL, G_ASHR, and G_LSHR must preserve its
value as a (small) unsigned integer, therefore its incorrect to widen it
in any way but by zero extending it.

G_SHL was using G_ANYEXT and G_ASHR - G_SEXT (which is correct for their
destination and first source operands, but not the "number of bits to
shift" operand).

Generally, shifts aren't as similar to regular binary operations as it
might seem, for instance, they aren't commutative nor associative and
the second source operand usually requires a special treatment.

Reviewers: bogner, javed.absar, aivchenk, rovka

Reviewed By: bogner

Subscribers: igorb, kristof.beyls, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331926 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[llvm-objcopy] Add --strip-symbol (-N) option
Paul Semel [Wed, 9 May 2018 21:36:54 +0000 (21:36 +0000)]
[llvm-objcopy] Add --strip-symbol (-N) option

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331924 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AMDGPU] Support horizontal vectorization of min/max.
Farhana Aleen [Wed, 9 May 2018 21:18:34 +0000 (21:18 +0000)]
[AMDGPU] Support horizontal vectorization of min/max.

Author: FarhanaAleen

Reviewed By: rampitec

Subscribers: AMDGPU

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331920 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAMDGPU: Ignore any_extend in mul24 combine
Matt Arsenault [Wed, 9 May 2018 21:11:35 +0000 (21:11 +0000)]
AMDGPU: Ignore any_extend in mul24 combine

If a multiply is truncated, SimplifyDemandedBits
sometimes turns a zero_extend of the inputs into an
any_extend, which makes the known bits computation unhelpful.
Ignore these and compute known bits for the underlying value,
since we insert the correct extend type after.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331919 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Hexagon] Add patterns for vector shift-and-accumulate
Krzysztof Parzyszek [Wed, 9 May 2018 21:10:41 +0000 (21:10 +0000)]
[Hexagon] Add patterns for vector shift-and-accumulate

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331918 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAMDGPU: Handle partial shift reduction for variable shifts
Matt Arsenault [Wed, 9 May 2018 20:52:54 +0000 (20:52 +0000)]
AMDGPU: Handle partial shift reduction for variable shifts

If the variable shift amount has known bits, we can still reduce
the shift.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331917 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAMDGPU: Partially shrink 64-bit shifts if reduced to 16-bit
Matt Arsenault [Wed, 9 May 2018 20:52:43 +0000 (20:52 +0000)]
AMDGPU: Partially shrink 64-bit shifts if reduced to 16-bit

This is an extension of an existing combine to reduce wider
shls if the result fits in the final result type. This
introduces the same combine, but reduces the shift to a middle
sized type to avoid the slow 64-bit shift.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331916 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Fix Broadwell's Shuffle256 schedule classes load latency values.
Simon Pilgrim [Wed, 9 May 2018 19:27:48 +0000 (19:27 +0000)]
[X86] Fix Broadwell's Shuffle256 schedule classes load latency values.

Allows us to remove some unnecessary InstRW overrides.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331913 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Merge instregex patterns to reduce InstrRW compile time.
Simon Pilgrim [Wed, 9 May 2018 19:04:15 +0000 (19:04 +0000)]
[X86] Merge instregex patterns to reduce InstrRW compile time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331911 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAMDGPU: Add combine for trunc of bitcast from build_vector
Matt Arsenault [Wed, 9 May 2018 18:37:39 +0000 (18:37 +0000)]
AMDGPU: Add combine for trunc of bitcast from build_vector

If the truncate is only accessing the first element of the vector,
we can use the original source value.

This helps with some combine ordering issues after operations are
lowered to integer operations between bitcasts of build_vector.
In particular it stops unnecessarily materializing the unused
top half of a vector in some cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331909 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Hexagon] Check the end of the correct container (fix typo)
Krzysztof Parzyszek [Wed, 9 May 2018 18:33:59 +0000 (18:33 +0000)]
[Hexagon] Check the end of the correct container (fix typo)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331907 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAMDGPU: Stop special casing constant indexes of extract_vector_elt
Matt Arsenault [Wed, 9 May 2018 18:29:26 +0000 (18:29 +0000)]
AMDGPU: Stop special casing constant indexes of extract_vector_elt

The same result folds out of the dynamic expansion logic if the
index is constant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331906 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[llvm-rc] Handle C preprocessor output
Martin Storsjo [Wed, 9 May 2018 18:21:03 +0000 (18:21 +0000)]
[llvm-rc] Handle C preprocessor output

When preprocessing resource scripts (which can easily be done outside
of llvm-rc), included headers can leave behind C declarations (despite
preprocessing with -DRC_INVOKED), that can't be parsed by a resource
compiler.

This is handled in all of rc.exe, by parsing the preprocessor output
line markers and ignoring content from files named *.h and *.c,
documented at [1].

In addition to this filtering, strip out any other preprocessor directive
that is left behind (like pragmas) which also can't be handled by the
tokenizer.

The added test uses both standard #line markers (supported by rc.exe) and
GNU style extended line markers, thus this test doesn't pass with rc.exe,
but passes with GNU windres. (Windres on the other hand doesn't filter
out files named *.c, only *.h.)

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

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa381033(v=vs.85).aspx

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331903 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[llvm-rc] Add support for the RCDATA resource type
Martin Storsjo [Wed, 9 May 2018 18:20:56 +0000 (18:20 +0000)]
[llvm-rc] Add support for the RCDATA resource type

This is the same as any other user defined resource, but with
a specific allocated resource type number.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331902 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[llvm-rc] Allow -1 for control IDs in old style dialogs with 16 bit fields
Martin Storsjo [Wed, 9 May 2018 18:20:49 +0000 (18:20 +0000)]
[llvm-rc] Allow -1 for control IDs in old style dialogs with 16 bit fields

-1 is commonly used as ID for controls that one don't want to
refer to later. For DIALOG resources, the IDs are 16 bit numbers,
and -1 gets interpreted as UINT32_MAX earlier, which then later is
too large to write into a uint16_t.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331901 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago Reapplying r331819 [GlobalISel][Legalizer] More concise and faster widenScalar...
Roman Tereshin [Wed, 9 May 2018 17:28:18 +0000 (17:28 +0000)]
Reapplying r331819 [GlobalISel][Legalizer] More concise and faster widenScalar, NFC

    The commit was a suspect for clang-cmake-aarch64-global-isel and
    clang-cmake-aarch64-quick bot failures, proved to be innocent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331898 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agollvm-mca: Add missing includes
David Blaikie [Wed, 9 May 2018 17:28:10 +0000 (17:28 +0000)]
llvm-mca: Add missing includes

Move the header include in the primary source file to the top to
validate that it doesn't depend on any other inclusions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331897 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DAGCombiner] In visitBITCAST when trying to constant fold the bitcast, only call...
Craig Topper [Wed, 9 May 2018 17:14:27 +0000 (17:14 +0000)]
[DAGCombiner] In visitBITCAST when trying to constant fold the bitcast, only call getBitcast if its an fp->int or int->fp conversion even when before legalize ops.

Previously if !LegalOperations we would blindly call getBitcast and hope that getNode would constant fold it. But if the conversion is between a vector and a scalar, getNode has no simplification.

This means we would just get back the original N. We would then return that N which would make the caller of visitBITCAST think that we used CombineTo and did our own worklist management. This prevents target specific optimizations from being called for vector/scalar bitcasts until after legal operations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331896 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] snprintf optimizations
David Bolvansky [Wed, 9 May 2018 16:09:31 +0000 (16:09 +0000)]
[InstCombine] snprintf optimizations

Reviewers: spatel, efriedma, majnemer, rja, bkramer

Reviewed By: rja, bkramer

Subscribers: rja, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331889 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DAGCombine] Change store merge candidates check cut off to 1024.
Amara Emerson [Wed, 9 May 2018 15:53:06 +0000 (15:53 +0000)]
[DAGCombine] Change store merge candidates check cut off to 1024.

The previous value of 8192 resulted in severe compile time hits in
some pathological cases.

rdar://39781410

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331888 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Hexagon] Fix sanitizer error about using -1u in variable of enum type
Krzysztof Parzyszek [Wed, 9 May 2018 15:44:40 +0000 (15:44 +0000)]
[Hexagon] Fix sanitizer error about using -1u in variable of enum type

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331887 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[LV] Change MaxVectorSize bound to 256 in assertion, NFC otherwise
Krzysztof Parzyszek [Wed, 9 May 2018 15:18:12 +0000 (15:18 +0000)]
[LV] Change MaxVectorSize bound to 256 in assertion, NFC otherwise

It's possible to have a vector of 256 bytes in HVX code on Hexagon
(vector pair in 128-byte mode).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331885 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAPFloat/x87: Fix string conversion for "unnormal" values (pr35860)
Pavel Labath [Wed, 9 May 2018 15:13:45 +0000 (15:13 +0000)]
APFloat/x87: Fix string conversion for "unnormal" values (pr35860)

Summary:
Unnormal values are a feature of some very old x87 processors. We handle
them correctly for the most part -- the only exception was an unnormal
value whose significand happened to be zero. In this case the APFloat
was still initialized as normal number (category = fcNormal), but a
subsequent toString operation would assert because the math would
produce nonsensical values for the zero significand.

During review, it was decided that the correct way to fix this is to
treat all unnormal values as NaNs (as that is what any >=386 processor
will do).

The issue was discovered because LLDB would crash when trying to print
some "long double" values.

Reviewers: skatkov, scanon, gottesmm

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331884 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Hexagon] Simplify MCCodeEmitter, move data to tables
Krzysztof Parzyszek [Wed, 9 May 2018 15:02:04 +0000 (15:02 +0000)]
[Hexagon] Simplify MCCodeEmitter, move data to tables

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331883 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[LV] Add lit testcase for bitcast problem. NFC
Karl-Johan Karlsson [Wed, 9 May 2018 13:34:57 +0000 (13:34 +0000)]
[LV] Add lit testcase for bitcast problem. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331878 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Support/Path] Make handling of paths like "///" consistent
Pavel Labath [Wed, 9 May 2018 13:21:16 +0000 (13:21 +0000)]
[Support/Path] Make handling of paths like "///" consistent

Summary:
Various path functions were not treating paths consisting of slashes
alone consistently. For example, the iterator-based accessors decomposed the
path "///" into two elements: "/" and ".". This is not too bad, but it
is different from the behavior specified by posix:
```
A pathname that contains ***at least one non-slash character*** and that
ends with one or more trailing slashes shall be resolved as if a single
dot character ( '.' ) were appended to the pathname.
```
More importantly, this was different from how we treated the same path
in the filename+parent_path functions, which decomposed this path into
"." and "". This was completely wrong as it lost the information that
this was an absolute path which referred to the root directory.

This patch fixes this behavior by making sure all functions treat paths
consisting of (back)slashes alone the same way as "/". I.e., the
iterator-based functions will just report one component ("/"), and the
filename+parent_path will decompose them into "/" and "".

A slightly controversial topic here may be the treatment of "//". Posix
says that paths beginning with "//" may have special meaning and indeed
we have code which parses paths like "//net/foo/bar" specially. However,
as we were already not being consistent in parsing the "//" string
alone, and any special parsing for it would complicate the code further,
I chose to treat it the same way as longer sequences of slashes (which
are guaranteed to be the same as "/").

Another slight change of behavior is in the parsing of paths like
"//net//". Previously the last component of this path was ".". However,
as in our parsing the "//net" part in this path was the same as the
"drive" part in "c:\" and the next slash was the "root directory", it
made sense to treat "//net//" the same way as "//net/" (i.e., not to add
the extra "." component at the end).

Reviewers: zturner, rnk, dblaikie, Bigcheese

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331876 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AArch64] Improve cost of vector division by constant
Adhemerval Zanella [Wed, 9 May 2018 12:48:22 +0000 (12:48 +0000)]
[AArch64] Improve cost of vector division by constant

With custom lowering for vector MULLH{S,U}, it is now profitable to
vectorize a divide by constant loop for the custom types (v16i8, v8i16,
and v4i32).  The cost if based on TargetLowering::Build{S,U}DIV which
uses a multiply by constant plus adjustment to express a divide by
constant.

Both {u,s}mull{2} are expressed as Instruction::Mul and shifts by
Instruction::AShr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331873 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove 'abi-breaking-checks' lit feature.
Nico Weber [Wed, 9 May 2018 12:39:39 +0000 (12:39 +0000)]
Remove 'abi-breaking-checks' lit feature.

Its only two uses were removed in r311730.
Effectively reverts r304851 (but that code has removed around a bit since then).
https://reviews.llvm.org/D46619

clang side done in r331871.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331872 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "DWARFVerifier: Check "completeness" of .debug_names section"
Pavel Labath [Wed, 9 May 2018 12:26:19 +0000 (12:26 +0000)]
Revert "DWARFVerifier: Check "completeness" of .debug_names section"

The new verifier check has found an error in the
debug-names-name-collisions.ll test on the PS4 bot:

error: Name Index @ 0x0: Entry @ 0xdc: mismatched Name of DIE @ 0x23: index - _ZN3foo3fooE; debug_info - foo.

Reverting while I investigate whether this is a bug in the verifier or
the generator.

This reverts commit r331868.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331869 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDWARFVerifier: Check "completeness" of .debug_names section
Pavel Labath [Wed, 9 May 2018 12:06:17 +0000 (12:06 +0000)]
DWARFVerifier: Check "completeness" of .debug_names section

Summary:
This patch implements a check which makes sure all entries required by
the DWARF v5 specification are present in the Name Index. The algorithm
tries to follow the wording of Section 6.1.1.1 of the spec as closely as
possible.

The main deviation from it is that instead of a whitelist-based approach
in the spec "The name index must contain an entry for each debugging
information entry that defines a named subprogram, label, variable,
type, or namespace" I chose a blacklist-based one, where I consider
everything to be "in" and then remove the entries that don't make sense.
I did this because it has more potential for catching interesting cases
and the above is a bit vague (it uses plain words like "variable" and
"subprogram", but the rest of the section speaks about specific TAGs).

This approach has raised some interesting questions, the main one being
whether enumerator values should be indexed. The consensus seems to be
that they should, although it does not follow from section 6.1.1.1.
For the time being I made the verifier ignore these, as LLVM does not do
this yet, and I wanted to get a clean run when verifying generated debug
info.

Another interesting case was the DW_TAG_imported_declaration. It was not
immediately clear to me whether this should go in or not, but currently
it is not indexed, and (unlike the enumerators) in does not seem to cause
problems for LLDB, so I've also ignored it.

Reviewers: JDevlieghere, aprantl, dblaikie

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331868 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CostModel][X86] Split off SLM checks
Simon Pilgrim [Wed, 9 May 2018 11:42:34 +0000 (11:42 +0000)]
[CostModel][X86] Split off SLM checks

A future patch will require this and the diff is much better if we perform the split separately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331867 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[InstCombine] snprintf optimizations"
Benjamin Kramer [Wed, 9 May 2018 11:38:57 +0000 (11:38 +0000)]
Revert "[InstCombine] snprintf optimizations"

This reverts commit r331849. It miscompiles
snprintf(buf, sizeof(buf), "%s", "any constant string); into
memcpy(buf, "%s", sizeof("any constant string"));

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331866 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Mark tests using -debug-only as REQUIRES: asserts
Benjamin Kramer [Wed, 9 May 2018 11:17:30 +0000 (11:17 +0000)]
[DebugInfo] Mark tests using -debug-only as REQUIRES: asserts

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331865 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Cleanup WriteFStore/WriteVecStore schedules
Simon Pilgrim [Wed, 9 May 2018 11:01:16 +0000 (11:01 +0000)]
[X86] Cleanup WriteFStore/WriteVecStore schedules

MOVNTPD/MOVNTPS should be WriteFStore

Standardized BDW/HSW/SKL/SKX WriteFStore/WriteVecStore - fixes some missed instregex patterns. (V)MASKMOVDQU was already using the default, its costs gets increased but is still nowhere near the real cost of that nasty instruction....

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331864 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[mips] Move conditional moves out of isCodeGenOnly
Simon Dardis [Wed, 9 May 2018 10:33:21 +0000 (10:33 +0000)]
[mips] Move conditional moves out of isCodeGenOnly

Reviewers: atanasyan, smaksimovic, abeserminji

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331863 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[COFF] Improve correctness of def parsing for GNU features
Martin Storsjo [Wed, 9 May 2018 09:21:53 +0000 (09:21 +0000)]
[COFF] Improve correctness of def parsing for GNU features

The operator == used for exporting a function with a different
name in the DLL compared to the name in the import library
(which is useful for adding linker level aliases for function
in the import library) is a feature distinct and different from
the operator = used for exporting a function with a different
name (both in import library and DLL) than in the implementation
producing the DLL.

When creating an import library using dlltool, from a def file that
contains forwards (Func = OtherDll.Func), this shouldn't affect the
produced import library, which should still behave just as if it
was a normal exported function.

This clears a lot of confusion and subtle misunderstandings, and
avoids a parameter that was used to avoid creating weak aliases
when invoked from lld. (This parameter was added previously due to
the existing conflation of the two features.)

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331859 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd a test for r331746.
Hans Wennborg [Wed, 9 May 2018 08:20:14 +0000 (08:20 +0000)]
Add a test for r331746.

Thanks to pcc for creating the test file!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331854 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Fix test failed due to debug-label-mi.ll and debug-label-opt.ll
Shiva Chen [Wed, 9 May 2018 07:09:28 +0000 (07:09 +0000)]
[DebugInfo] Fix test failed due to debug-label-mi.ll and debug-label-opt.ll

Make these two test cases more generic for other architectures.
Please refer to '[DebugInfo] Convert intrinsic llvm.dbg.label to
MachineInstr.'

Patch by Hsiangkai Wang

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331853 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MergedLoadStoreMotion] Fix a debug invariant bug in mergeStores
Bjorn Pettersson [Wed, 9 May 2018 06:52:12 +0000 (06:52 +0000)]
[MergedLoadStoreMotion] Fix a debug invariant bug in mergeStores

Summary:
MergedLoadStoreMotion::mergeStores is using some heuristics
to limit the amount of stores that it tries to sink (see
MagicCompileTimeControl in MergedLoadStoreMotion.cpp). The
heuristic involves counting the number of instructions in
one of the basic blocks that is part of the transformation.

We now ignore dbg intrinsics when counting instruction for
the MagicCompileTimeControl heuristic. This to make sure that
the amount of stores that are sunk doesn't depend on the amount
of debug information (if -g is used or not).

Reviewers: Gerolf, davide, majnemer

Reviewed By: davide

Subscribers: dberlin, bjope, aprantl, JDevlieghere, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331852 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[LLVM-C] Correct types in Go bindings
Robert Widmann [Wed, 9 May 2018 06:45:28 +0000 (06:45 +0000)]
[LLVM-C] Correct types in Go bindings

Summary: Fixes a test failure introduced in rL331114.

Reviewers: whitequark

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331850 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] snprintf optimizations
David Bolvansky [Wed, 9 May 2018 06:34:20 +0000 (06:34 +0000)]
[InstCombine] snprintf optimizations

Reviewers: spatel, efriedma, majnemer, rja

Reviewed By: rja

Subscribers: rja, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331849 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Fix test failed due to new DISubprogram attributes.
Shiva Chen [Wed, 9 May 2018 06:22:39 +0000 (06:22 +0000)]
[DebugInfo] Fix test failed due to new DISubprogram attributes.

Please refer to '[DebugInfo] Add DILabel metadata and intrinsic
llvm.dbg.label'. I have renamed the 'variables' attributes to
'retainedNodes' to include local variables and local labels for the
function.

Patch by Hsiangkai Wang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331848 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Combine (vXi1 (bitcast (-1)))) and (vXi1 (bitcast (0))) to all ones or all...
Craig Topper [Wed, 9 May 2018 06:07:20 +0000 (06:07 +0000)]
[X86] Combine (vXi1 (bitcast (-1)))) and (vXi1 (bitcast (0))) to all ones or all zeros vXi1 vector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331847 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r331816 and r331820 - [globalisel] Add a combiner helpers for extending loads...
Daniel Sanders [Wed, 9 May 2018 05:00:17 +0000 (05:00 +0000)]
Revert r331816 and r331820 - [globalisel] Add a combiner helpers for extending loads and use them in a pre-legalize combiner for AArch64

Reverting this to see if the clang-cmake-aarch64-global-isel and
clang-cmake-aarch64-quick bots are failing because of this commit.
We know it wasn't r331819.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331846 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Examine all uses of isDebugValue() for debug instructions.
Shiva Chen [Wed, 9 May 2018 02:42:00 +0000 (02:42 +0000)]
[DebugInfo] Examine all uses of isDebugValue() for debug instructions.

Because we create a new kind of debug instruction, DBG_LABEL, we need to
check all passes which use isDebugValue() to check MachineInstr is debug
instruction or not. When expelling debug instructions, we should expel
both DBG_VALUE and DBG_LABEL. So, I create a new function,
isDebugInstr(), in MachineInstr to check whether the MachineInstr is
debug instruction or not.

This patch has no new test case. I have run regression test and there is
no difference in regression test.

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

Patch by Hsiangkai Wang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331844 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Convert intrinsic llvm.dbg.label to MachineInstr.
Shiva Chen [Wed, 9 May 2018 02:41:08 +0000 (02:41 +0000)]
[DebugInfo] Convert intrinsic llvm.dbg.label to MachineInstr.

In order to convert LLVM IR to MachineInstr, we need a new TargetOpcode,
DBG_LABEL, to ‘lower’ intrinsic llvm.dbg.label. The patch
creates this new TargetOpcode and convert intrinsic llvm.dbg.label to
MachineInstr through SelectionDAG.

In SelectionDAG, debug information is stored in SDDbgInfo. We create a
new data member of SDDbgInfo for labels and use the new data member,
SDDbgLabel, to create DBG_LABEL MachineInstr.

The new DBG_LABEL MachineInstr uses label metadata from LLVM IR as its
parameter. So, the backend could get metadata information of labels from
DBG_LABEL MachineInstr.

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

Patch by Hsiangkai Wang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331842 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
Shiva Chen [Wed, 9 May 2018 02:40:45 +0000 (02:40 +0000)]
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.

In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is

!DILabel(scope: !1, name: "foo", file: !2, line: 3)

We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is

llvm.dbg.label(metadata !1)

It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.

We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.

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

Patch by Hsiangkai Wang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331841 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r331819 [GlobalISel][Legalizer] More concise and faster widenScalar, NFC
Roman Tereshin [Wed, 9 May 2018 01:43:12 +0000 (01:43 +0000)]
Revert r331819 [GlobalISel][Legalizer] More concise and faster widenScalar, NFC

Reverting this to see if the clang-cmake-aarch64-global-isel and
clang-cmake-aarch64-quick bots are failing because of this commit

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331839 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[RuntimeDyld][MachO] Properly handle thumb to thumb calls within a section.
Lang Hames [Wed, 9 May 2018 01:38:13 +0000 (01:38 +0000)]
[RuntimeDyld][MachO] Properly handle thumb to thumb calls within a section.

Previously thumb bits were only checked for external relocations (thumb to arm
code and vice-versa). This patch adds detection for thumb callees in the same
section asthe (also thumb) caller.

The MachO/Thumb test case is updated to cover this, and redundant checks
(handled by the MachO/ARM test) are removed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331838 91177308-0d34-0410-b5e6-96231b3b80d8