Commit Graph

31478 Commits

Author SHA1 Message Date
Sam Clegg
65e284ec3b [WebAssembly] Improve libObject support for wasm imports and exports
Previously we had only supported the importing and
exporting of functions and globals.

Also, add usefull overload of getWasmSymbol() and
getNumberOfSymbols() in support of lld port.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302601 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 23:48:41 +00:00
Easwaran Raman
9051122d57 [ProfileSummary] Make getProfileCount a non-static member function.
This change is required because the notion of count is different for
sample profiling and getProfileCount will need to determine the
underlying profile type.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302597 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 23:21:10 +00:00
Lang Hames
ab3dba86f9 [ExecutionEngine] Make RuntimeDyld::MemoryManager responsible for tracking EH
frames.

RuntimeDyld was previously responsible for tracking allocated EH frames, but it
makes more sense to have the RuntimeDyld::MemoryManager track them (since the
frames are allocated through the memory manager, and written to memory owned by
the memory manager). This patch moves the frame tracking into
RTDyldMemoryManager, and changes the deregisterFrames method on
RuntimeDyld::MemoryManager from:

void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size);

to:

void deregisterEHFrames();

Separating this responsibility will allow ORC to continue to throw the
RuntimeDyld instances away post-link (saving a few dozen bytes per lazy
function) while properly deregistering frames when modules are unloaded.

This patch also updates ORC to call deregisterEHFrames when modules are
unloaded. This fixes a bug where an exception that tears down the JIT can then
unwind through dangling EH frames that have been deallocated but not
deregistered, resulting in UB.

For people using SectionMemoryManager this should be pretty much a no-op. For
people with custom allocators that override registerEHFrames/deregisterEHFrames,
you will now be responsible for tracking allocated EH frames.

Reviewed in https://reviews.llvm.org/D32829



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302589 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 21:32:18 +00:00
Reid Kleckner
e32aebf279 [codeview] Check for a DIExpression offset for local variables
Fixes inalloca parameters, which previously all pointed to the same
offset. Extend the test to use llvm-readobj so that we can test the
offset in a readable way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302578 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 19:59:29 +00:00
Adrian Prantl
8b2dee8975 Make it illegal for two Functions to point to the same DISubprogram
As recently discussed on llvm-dev [1], this patch makes it illegal for
two Functions to point to the same DISubprogram and updates
FunctionCloner to also clone the debug info of a function to conform
to the new requirement. To simplify the implementation it also factors
out the creation of inlineAt locations from the Inliner into a
general-purpose utility in DILocation.

[1] http://lists.llvm.org/pipermail/llvm-dev/2017-May/112661.html
<rdar://problem/31926379>

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

This reapplies r302469 with a fix for a bot failure (reparentDebugInfo
now checks for the case the orig and new function are identical).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302576 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 19:47:37 +00:00
Serge Guelton
d35f86ef8f Suppress all uses of LLVM_END_WITH_NULL. NFC.
Use variadic templates instead of relying on <cstdarg> + sentinel.
This enforces better type checking and makes code more readable.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302571 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 19:31:13 +00:00
Craig Topper
80f6556e8a [APInt] Remove return value from tcFullMultiply.
The description says it returns the number of words needed to represent the results. But the way it was coded it always returns (lhsWords + rhsWords) or (lhsWords + rhsWords - 1). But the result could be even smaller than that and it wouldn't tell you.

No one uses the result today so rather than try to fix it, just remove it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302551 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 16:47:33 +00:00
Tim Shen
f52671da9b [Atomic] Remove IsStore/IsLoad in the interface, and pass the instruction instead. NFC.
Now both emitLeadingFence and emitTrailingFence take the instruction
itself, instead of taking IsLoad/IsStore pairs.
Instruction::mayReadFromMemory and Instrucion::mayWriteToMemory are used
for determining those two booleans.

The instruction argument is also useful for later D32763, in
emitTrailingFence. For emitLeadingFence, it seems to have cleaner
interface with the proposed change.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302539 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 15:27:17 +00:00
Hans Wennborg
1f81185df2 Revert r302469 "Make it illegal for two Functions to point to the same DISubprogram"
This caused PR32977.

Original commit message:

> Make it illegal for two Functions to point to the same DISubprogram
>
> As recently discussed on llvm-dev [1], this patch makes it illegal for
> two Functions to point to the same DISubprogram and updates
> FunctionCloner to also clone the debug info of a function to conform
> to the new requirement. To simplify the implementation it also factors
> out the creation of inlineAt locations from the Inliner into a
> general-purpose utility in DILocation.
>
> [1] http://lists.llvm.org/pipermail/llvm-dev/2017-May/112661.html
> <rdar://problem/31926379>
>
> Differential Revision: https://reviews.llvm.org/D32975

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302533 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 14:44:15 +00:00
Serge Pavlov
1f4a80fdc1 Add extra operand to CALLSEQ_START to keep frame part set up previously
Using arguments with attribute inalloca creates problems for verification
of machine representation. This attribute instructs the backend that the
argument is prepared in stack prior to  CALLSEQ_START..CALLSEQ_END
sequence (see http://llvm.org/docs/InAlloca.htm for details). Frame size
stored in CALLSEQ_START in this case does not count the size of this
argument. However CALLSEQ_END still keeps total frame size, as caller can
be responsible for cleanup of entire frame. So CALLSEQ_START and
CALLSEQ_END keep different frame size and the difference is treated by
MachineVerifier as stack error. Currently there is no way to distinguish
this case from actual errors.

This patch adds additional argument to CALLSEQ_START and its
target-specific counterparts to keep size of stack that is set up prior to
the call frame sequence. This argument allows MachineVerifier to calculate
actual frame size associated with frame setup instruction and correctly
process the case of inalloca arguments.

The changes made by the patch are:
- Frame setup instructions get the second mandatory argument. It
  affects all targets that use frame pseudo instructions and touched many
  files although the changes are uniform.
- Access to frame properties are implemented using special instructions
  rather than calls getOperand(N).getImm(). For X86 and ARM such
  replacement was made previously.
- Changes that reflect appearance of additional argument of frame setup
  instruction. These involve proper instruction initialization and
  methods that access instruction arguments.
- MachineVerifier retrieves frame size using method, which reports sum of
  frame parts initialized inside frame instruction pair and outside it.

The patch implements approach proposed by Quentin Colombet in
https://bugs.llvm.org/show_bug.cgi?id=27481#c1.
It fixes 9 tests failed with machine verifier enabled and listed
in PR27481.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302527 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 13:35:13 +00:00
Amara Emerson
8f1f7ce9d1 Introduce experimental generic intrinsics for horizontal vector reductions.
- This change allows targets to opt-in to using them instead of the log2
  shufflevector algorithm.
- The SLP and Loop vectorizers have the common code to do shuffle reductions
  factored out into LoopUtils, and now have a unified interface for generating
  reductions regardless of the preference of the target. LoopUtils now uses TTI
  to determine what kind of reductions the target wants to handle.
- For CodeGen, basic legalization support is added.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302514 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 10:43:25 +00:00
Greg Clayton
cca9d00b74 Add const to "DWARFDie &Die" in a few functions as they can't change the DWARFDie.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302471 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 21:29:17 +00:00
Adrian Prantl
28bd5d128c Make it illegal for two Functions to point to the same DISubprogram
As recently discussed on llvm-dev [1], this patch makes it illegal for
two Functions to point to the same DISubprogram and updates
FunctionCloner to also clone the debug info of a function to conform
to the new requirement. To simplify the implementation it also factors
out the creation of inlineAt locations from the Inliner into a
general-purpose utility in DILocation.

[1] http://lists.llvm.org/pipermail/llvm-dev/2017-May/112661.html
<rdar://problem/31926379>

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302469 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 21:17:08 +00:00
Matthias Braun
ca58fab8c4 STLExtras: Fix enumerate() documentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302467 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 21:10:58 +00:00
Greg Clayton
a086b24688 Fix typo "veify" to "verify".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302466 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 20:53:00 +00:00
Zachary Turner
bb0606e8de Add some useful helper methods / operators to TypeIndex.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302460 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 19:46:37 +00:00
Zachary Turner
886c6baf06 [BitVector] Make find_prev member function const.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302458 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 19:45:55 +00:00
Zachary Turner
f019c6b219 [CodeView] Add support for random access type visitors.
Previously type visitation was done strictly sequentially, and
TypeIndexes were computed by incrementing the TypeIndex of the
last visited record.  This works fine for situations like dumping,
but not when you want to visit types in random order.  For example,
in a debug session someone might lookup a symbol by name, find that
it has TypeIndex 10,000 and then want to go straight to TypeIndex
10,000.

In order to make this work, the visitation framework needs a mode
where it can plumb TypeIndices through the callback pipeline.  This
patch adds such a mode.  In doing so, it is necessary to provide
an alternative implementation of TypeDatabase that supports random
access, so that is done as well.

Nothing actually uses these random access capabilities yet, but
this will be done in subsequent patches.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302454 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 18:38:43 +00:00
Craig Topper
0f7e2baed5 [SCEV] Make setRange take ConstantRange by value instead of rvalue reference so we don't force anything on the caller.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302449 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 17:39:08 +00:00
Craig Topper
3f38291e28 [ValueTracking] Introduce a version of computeKnownBits that returns a KnownBits struct. Begin using it to replace internal usages of ComputeSignBit
This introduces a new interface for computeKnownBits that returns the KnownBits object instead of requiring it to be pre-constructed and passed in by reference.

This is a much more convenient interface as it doesn't require the caller to figure out the BitWidth to pre-construct the object. It's so convenient that I believe we can use this interface to remove the special ComputeSignBit flavor of computeKnownBits.

As a step towards that idea, this patch replaces all of the internal usages of ComputeSignBit with this new interface. As you can see from the patch there were a couple places where we called ComputeSignBit which really called computeKnownBits, and then called computeKnownBits again directly. I've reduced those places to only making one call to computeKnownBits. I bet there are probably external users that do it too.

A future patch will update the external users and remove the ComputeSignBit interface. I'll also working on moving more locations to the KnownBits returning interface for computeKnownBits.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302437 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 16:22:48 +00:00
Geoff Berry
6922382ead Fix comment typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302432 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 15:33:08 +00:00
Zvi Rackover
f4d18ab589 IR: Add a shufflevector mask commutation helper function. NFC.
Summary:
Following up on Sanjay's suggetion in D32955, move this functionality
into ShuffleVectornstruction.

Reviewers: spatel, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302420 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 12:40:18 +00:00
Martin Storsjo
b7c80c3cd2 [ARM] Clear the constant pool cache on explicit .ltorg directives
Multiple ldr pseudoinstructions with the same constant value will
reuse the same constant pool entry. However, if the constant pool
is explicitly flushed with a .ltorg directive, we should not try
to reference constants in the previous pool any longer, since they
may be out of range.

This fixes assembling hand-written assembler source which repeatedly
loads the same constant value, across a binary size larger than the
pc-relative fixup range for ldr instructions (4096 bytes). Such
assembler source already uses explicit .ltorg instructions to emit
constant pools with regular intervals. However if we try to reuse
constants emitted in earlier pools, they end up out of range.

This makes the output of the testcase match what binutils gas does
(prior to this patch, it would fail to assemble).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302416 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 10:26:24 +00:00
Dean Michael Berris
638f2cdc22 [XRay] Custom event logging intrinsic
This patch introduces an LLVM intrinsic and a target opcode for custom event
logging in XRay. Initially, its use case will be to allow users of XRay to log
some type of string ("poor man's printf"). The target opcode compiles to a noop
sled large enough to enable calling through to a runtime-determined relative
function call. At runtime, when X-Ray is enabled, the sled is replaced by
compiler-rt with a trampoline to the logic for creating the custom log entries.

Future patches will implement the compiler-rt parts and clang-side support for
emitting the IR corresponding to this intrinsic.

Reviewers: timshen, dberris

Subscribers: igorb, pelikan, rSerge, timshen, echristo, dberris, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302405 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 05:45:21 +00:00
Craig Topper
1e5158d3c8 [APInt] Add support for multiplying by a uint64_t.
This makes multiply similar to add, sub, xor, and, and or.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302402 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 04:55:09 +00:00
Eric Beckmann
20c59f10e5 Hopefully one last commit to fix this patch, addresses string reference
issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302401 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 02:47:42 +00:00
Eric Beckmann
8d0cc56596 Update llvm-readobj -coff-resources to display tree structure.
Summary: Continue making updates to llvm-readobj to display resource sections.  This is necessary for testing the up and coming cvtres tool.

Reviewers: zturner

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302399 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 02:47:07 +00:00
Eric Beckmann
baef3d539e Revert "Hopefully one last commit to fix this patch, addresses string reference"
Summary:
This reverts commit 56beec1b1cfc6d263e5eddb7efff06117c0724d2.

Revert "Quick fix to D32609, it seems .o files are not transferred in all cases."

This reverts commit 7652eecd29cfdeeab7f76f687586607a99ff4e36.

Revert "Update llvm-readobj -coff-resources to display tree structure."

This reverts commit 422b62c4d302cfc92401418c2acd165056081ed7.

Reviewers: zturner

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302397 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 02:25:03 +00:00
Eric Beckmann
fffb7130dd Hopefully one last commit to fix this patch, addresses string reference
issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302395 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 01:48:55 +00:00
Eric Beckmann
4899f6643e Update llvm-readobj -coff-resources to display tree structure.
Summary: Continue making updates to llvm-readobj to display resource sections.  This is necessary for testing the up and coming cvtres tool.

Reviewers: zturner

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302386 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 22:47:22 +00:00
Craig Topper
677051d58f [ConstantRange][SimplifyCFG] Add a helper method to allow SimplifyCFG to determine if a ConstantRange has more than 8 elements without requiring an allocation if the ConstantRange is 64-bits wide.
Previously SimplifyCFG used getSetSize which returns an APInt that is 1 bit wider than the ConstantRange's bit width. In the reasonably common case that the ConstantRange is 64-bits wide, this requires returning a 65-bit APInt. APInt's can only store 64-bits without a memory allocation so this is inefficient.

The new method takes the 8 as an input and tells if the range contains more than that many elements without requiring any wider math.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302385 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 22:22:11 +00:00
Craig Topper
34ad4ae921 [ConstantRange] Remove 'Of' from name of ConstantRange::isSizeStrictlySmallerThanOf so that it reads better. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302383 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 21:48:08 +00:00
Lang Hames
33aa99e46a [Orc] Remove trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302377 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 20:39:46 +00:00
Lang Hames
e3f371483f Make llvm-rtdlyd -check preserve automatic address mappings made by RuntimeDyld.
Currently llvm-rtdyld in -check mode will map sections to back-to-back 4k
aligned slabs starting at 0x1000. Automatically remapping sections by default is
helpful because it quickly exposes relocation bugs due to use of local addresses
rather than load addresses (these would silently pass if the load address was
not remapped). These mappings can be explicitly overridden on a per-section
basis using llvm-rtdlyd's -map-section option. This patch extends this scheme to
also preserve any mappings made by RuntimeDyld itself. Preserving RuntimeDyld's
automatic mappings allows us to write test cases to verify that these automatic
mappings have been applied.

This will allow the fix in https://reviews.llvm.org/D32899 to be tested with
llvm-rtdyld -check.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302372 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 17:19:53 +00:00
Craig Topper
038bc52dc9 [SCEV] Use move semantics in ScalarEvolution::setRange
Summary: This makes setRange take ConstantRange by rvalue reference since most callers were passing an unnamed temporary ConstantRange. We can then move that ConstantRange into the DenseMap caches. For the callers that weren't passing a temporary, I've added std::move to to the local variable being passed.

Reviewers: sanjoy, mzolotukhin, efriedma

Reviewed By: sanjoy

Subscribers: takuto.ikuta, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302371 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 16:28:17 +00:00
Sanjoy Das
8582763b65 Remove unnecessary const_cast
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302368 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 05:29:36 +00:00
Lang Hames
98dab84b5c Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302366 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07 03:54:53 +00:00
Saleem Abdulrasool
731d5fe6e9 COFF: add ARM64 relocation types
Add the ARM64 COFF relocation types.  This will be needed to add support
for the AArch64 Windows object file emission support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302365 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-06 23:48:02 +00:00
Brian Gesiak
8a886c7975 [Analysis] Print out unreachable loops
Summary:
When writing a loop pass I made a mistake and hit the assertion
"Unreachable block in loop". Later, I hit an assertion when I called
`BasicBlock::eraseFromParent()` incorrectly: "Use still stuck around
after Def is destroyed". This latter assertion, however, printed out
exactly which value is being deleted and what uses remain, which helped
me debug the issue.

To help people debugging their loop passes in the future, print out
exactly which basic block is unreachable in a loop.

Reviewers: sanjoy, hfinkel, mehdi_amini

Reviewed By: mehdi_amini

Subscribers: mzolotukhin

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302354 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-06 16:22:53 +00:00
Kostya Serebryany
9d90a01faf [sanitizer-coverage] implement -fsanitize-coverage=no-prune,... instead of a hidden -mllvm flag. llvm part.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302319 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 23:14:40 +00:00
Quentin Colombet
ce22b10a6e [RegisterBankInfo] Uniquely allocate instruction mapping.
This is a step toward having statically allocated instruciton mapping.
We are going to tablegen them eventually, so let us reflect that in
the API.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302316 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 22:48:22 +00:00
Craig Topper
58d2d9869a [BitVector] Improve the description of the BitVector::clear to say it removes the bits rather than clearing since clearing could be interpreted as just zeroing. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302315 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 22:46:40 +00:00
Eugene Zelenko
e5dc33d4f6 [IR] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302310 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 22:30:37 +00:00
Easwaran Raman
66092ae0e8 Override invalidate of ProfileSummaryInfo to return false.
Differential revision: https://reviews.llvm.org/D32775

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302308 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 22:15:09 +00:00
Matthias Braun
97beda0626 ARM: Compute MaxCallFrame size early
This exposes a method in MachineFrameInfo that calculates
MaxCallFrameSize and calls it after instruction selection in the ARM
target.

This avoids
ARMBaseRegisterInfo::canRealignStack()/ARMFrameLowering::hasReservedCallFrame()
giving different answers in early/late phases of codegen.

The testcase shows a particular nasty example result of that where we
would fail to properly align an alloca.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302303 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 22:04:05 +00:00
Zachary Turner
4a6f9ee16e [CodeView] Reserve TypeDatabase records up front.
Most of the time we know exactly how many type records we
have in a list, and we want to use the visitor to deserialize
them into actual records in a database.  Previously we were
just using push_back() every time without reserving the space
up front in the vector.  This is obviously terrible from a
performance standpoint, and it's not uncommon to have PDB
files with half a million type records, where the performance
degredation was quite noticeable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302302 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 22:02:37 +00:00
Zachary Turner
1ed19d1faa Fix -Wreorder warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302294 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 21:25:31 +00:00
Zachary Turner
ba512990af [StreamArray] Pipe the Offset through the constructor.
When randomly accessing an element by offset, we weren't passing
the offset through so if you called .offset() it would return a
value of 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302292 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 21:15:31 +00:00
Matthias Braun
0cb25a2a10 MIParser/MIRPrinter: Compute block successors if not explicitely specified
- MIParser: If the successor list is not specified successors will be
  added based on basic block operands in the block and possible
  fallthrough.

- MIRPrinter: Adds a new `simplify-mir` option, with that option set:
  Skip printing of block successor lists in cases where the
  parser is guaranteed to reconstruct it. This means we still print the
  list if some successor cannot be determined (happens for example for
  jump tables), if the successor order changes or branch probabilities
  being unequal.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302289 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 21:09:30 +00:00
Matthias Braun
738a26c4e2 TargetLibraryInfo: Introduce wcslen
wcslen is part of the C99 and C++98 standards.

- This introduces the function to TargetLibraryInfo.
- Also set attributes for wcslen in llvm::inferLibFuncAttributes().

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302278 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 20:25:50 +00:00
Sam Clegg
afe8111c69 [WebAssembly] Add ObjectYAML support for wasm name section
Differential Revision: https://reviews.llvm.org/D32841

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302266 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 18:12:34 +00:00
Craig Topper
ace8b39f82 [KnownBits] Add wrapper methods for setting and clear all bits in the underlying APInts in KnownBits.
This adds routines for reseting KnownBits to unknown, making the value all zeros or all ones. It also adds methods for querying if the value is zero, all ones or unknown.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302262 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 17:36:09 +00:00
Adrian McCarthy
dca600b49c Allow operator-> to work from a FixedStreamArrayIterator.
This is similar to my recent fix for VarStreamArrayIterator, but the cause
(and thus the fix) is subtley different.  The FixedStreamArrayIterator
iterates over a const Array, so the iterator's value type must be const.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302257 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 17:14:00 +00:00
Zachary Turner
6a4e43bdd4 [ADT] Add BitVector::find_prev.
This almost completes the matrix of all possible find
functions.

*EXISTING*
----------
find_first
find_first_unset
find_next
find_next_unset
find_last
find_last_unset

*NEW*
----
find_prev

*STILL MISSING*
---------------
find_prev_unset

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302254 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 17:00:04 +00:00
George Rimar
f93836e0ec [llvm-dwarfdump] - Add comment for maybeDecompress(). NFC.
Addresses post commit review comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302249 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 16:13:10 +00:00
George Rimar
a83f092580 [llvm-dwarfdump] - Print an error message if section decompression failed.
llvm-dwarfdump currently prints no message if decompression fails 
for some reason. I noticed that during work on one of LLD patches 
where LLD produced an broken output. It was a bit confusing to see
no output for section dumped and no any error message at all.

Patch adds error message for such cases.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302221 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 10:52:39 +00:00
Zachary Turner
8038a28b4b [ADT] A few minor improvements to BitVector
Fixes some spelling mistakes, uses a helper function, and
adds an additional test case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302208 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-05 00:19:57 +00:00
Zachary Turner
6bf4f87547 [pdb] Don't verify TPI hash values up front.
Verifying the hash values as we are currently doing
results in iterating every type record before the user
even tries to access the first one, and the API user
has no control over, or ability to hook into this
process.

As a result, when the user wants to iterate over types
to print them or index them, this results in a second
iteration over the same list of types.  When there's
upwards of 1,000,000 type records, this is obviously
quite undesirable.

This patch raises the verification outside of TpiStream
, and llvm-pdbdump hooks a hash verification visitor
into the normal dumping process.  So we still verify
the hash records, but we can do it while not requiring
a second iteration over the type stream.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302206 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 23:53:54 +00:00
Zachary Turner
505c76a926 [PDB] Don't build the entire source file list up front.
I tried to run llvm-pdbdump on a very large (~1.5GB) PDB to
try and identify show-stopping performance problems.  This
patch addresses the first such problem.

When loading the DBI stream, before anyone has even tried to
access a single record, we build an in memory map of every
source file for every module.  In the particular PDB I was
using, this was over 85 million files.  Specifically, the
complexity is O(m*n) where m is the number of modules and
n is the average number of source files (including headers)
per module.

The whole reason for doing this was so that we could have
constant time access to any module and any of its source
file lists.  However, we can still get O(1) access to the
source file list for a given module with a simple O(m)
precomputation, and access to the list of modules is
already O(1) anyway.

So this patches reduces the O(m*n) up-front precomputation
to an O(m) one, where n is ~6,500 and n*m is about 85 million
in my pathological test case.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302205 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 23:53:29 +00:00
Quentin Colombet
197e49d664 [RegisterBankInfo] Fix 80-col introduced in r293506.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302202 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 22:43:08 +00:00
Quentin Colombet
b39d7934a9 [GlobalISel] Add missing doxygen keyword for doxygen groups.
NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302201 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 22:43:04 +00:00
Craig Topper
09867ca676 [ConstantRange] Add LLVM_NODISCARD to ConstantRange since a large number of its methods construct new ConstantRange objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302194 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 21:29:50 +00:00
Craig Topper
7a94f0ce91 [Float2Int] Remove return of ConstantRange from seen method. Nothing uses it so it just creates and discards a ConstantRange object for no reason.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302193 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 21:29:45 +00:00
Sam Clegg
740b80d883 [WebAssembly] Add wasm symbol table support to llvm-objdump
Differential Revision: https://reviews.llvm.org/D32760

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302185 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 19:32:43 +00:00
Peter Collingbourne
e611018a3f Re-apply r302108, "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."
with a fix for the clang backend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302176 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 18:03:25 +00:00
Daniel Sanders
1a1fb4bbf2 [globalisel][tablegen] Add several GINodeEquiv's for operators that do not require additional support.
Summary:
As of this patch, 350 out of 3938 rules are currently imported.

Depends on D32229

Reviewers: qcolombet, kristof.beyls, rovka, t.p.northover, ab, aditya_nandakumar

Reviewed By: ab

Subscribers: dberris, llvm-commits, igorb

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302154 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 14:24:50 +00:00
Eric Liu
1c442aa9b7 Revert "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."
This reverts commit r302108. This causes crash in clang bootstrap with LTO.

Contacted the auther in the original commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302140 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 11:49:39 +00:00
Sam Parker
47d5da39f5 [ARM] ACLE Chapter 9 intrinsics
Added the integer data processing intrinsics from ACLE v2.1 Chapter 9
but I have missed out the saturation_occurred intrinsics for now. For
the instructions that read and write the GE bits, a chain is included
and the only instruction that reads these flags (sel) is only
selectable via the implemented intrinsic.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302126 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 07:31:28 +00:00
Dean Michael Berris
acf912e5ba [XRay] Create an Index of sleds per function
Summary:
This change adds a new section to the xray-instrumented binary that
stores an index into ranges of the instrumentation map, where sleds
associated with the same function can be accessed as an array. At
runtime, we can get access to this index by function ID offset allowing
for selective patching and unpatching by function ID.

Each entry in this new section (xray_fn_idx) will include two pointers
indicating the start and one past the end of the sleds associated with
the same function. These entries will be 16 bytes long on x86 and
aarch64. On arm, we align to 16 bytes anyway so the runtime has to take
that into consideration.

__{start,stop}_xray_fn_idx will be the symbols that the runtime will
look for when we implement the selective patching/unpatching by function
id APIs. Because XRay synthesizes the function id's in a monotonically
increasing manner at runtime now, implementations (and users) can use
this table to look up the sleds associated with a specific function.
This is useful in implementations that want to do things like:

  - Implement coverage mode for functions by patching everything
    pre-main, then as functions are encountered, the installed handler
    can unpatch the function that's been encountered after recording
    that it's been called.
  - Do "learning mode", so that the implementation can figure out some
    statistical information about function calls by function id for a
    time being, and then determine which functions are worth
    uninstrumenting at runtime.
  - Do "selective instrumentation" where an implementation can
    specifically instrument only certain function id's at runtime
    (either based on some external data, or through some other
    heuristics) instead of patching all the instrumented functions at
    runtime.

Reviewers: dblaikie, echristo, chandlerc, javed.absar

Subscribers: pelikan, aemerson, kpw, llvm-commits, rengolin

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302109 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 03:37:57 +00:00
Peter Collingbourne
df2206086c IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI.
When profiling a no-op incremental link of Chromium I found that the functions
computeImportForFunction and computeDeadSymbols were consuming roughly 10% of
the profile. The goal of this change is to improve the performance of those
functions by changing the map lookups that they were previously doing into
pointer dereferences.

This is achieved by changing the ValueInfo data structure to be a pointer to
an element of the global value map owned by ModuleSummaryIndex, and changing
reference lists in the GlobalValueSummary to hold ValueInfos instead of GUIDs.
This means that a ValueInfo will take a client directly to the summary list
for a given GUID.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302108 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 03:36:16 +00:00
NAKAMURA Takumi
7395a71ceb llvm/IR/Function.h: Prune an obsolete @param in r302060. [-Wdocumentation]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302106 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 02:01:18 +00:00
Michael Zolotukhin
805e09d964 [SCEV] createAddRecFromPHI: Optimize for the most common case.
Summary:
The existing implementation creates a symbolic SCEV expression every
time we analyze a phi node and then has to remove it, when the analysis
is finished. This is very expensive, and in most of the cases it's also
unnecessary. According to the data I collected, ~60-70% of analyzed phi
nodes (measured on SPEC) have the following form:
  PN = phi(Start, OP(Self, Constant))
Handling such cases separately significantly speeds this up.

Reviewers: sanjoy, pete

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302096 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 23:53:38 +00:00
Craig Topper
64c8cdfd4f [KnownBits] Add methods for determining if KnownBits is a constant value
This patch adds isConstant and getConstant for determining if KnownBits represents a constant value and to retrieve the value. Use them to simplify code.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302091 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 23:12:29 +00:00
Craig Topper
f78221855b [KnownBits] Add zext, sext, and trunc methods to KnownBits
This patch adds zext, sext, and trunc methods to KnownBits and uses them where possible.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302088 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 22:07:25 +00:00
Paul Robinson
2dbf23f50c clang-format and restyle DWARFFormValue before working on it. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302086 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 21:53:21 +00:00
Ahmed Bougacha
f007e3acca [AArch64] Make the TargetParser add CPU exts provided by the arch.
Otherwise, each CPU has to manually specify the extensions it supports,
even though they have to be a superset of the base arch extensions.
And when there's redundant data there's stale data, so most of the CPUs
lie about the features they support (almost none lists AEK_FP).

Instead, do the saner thing: add the optional extensions on top of the
base extensions provided by the architecture.

The ARM TargetParser has the same behavior.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302078 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 20:33:58 +00:00
Ahmed Bougacha
700df98ddd [AArch64] armv8-A doesn't have CRC.
That's only a required extension as of v8.1a.

Remove it from the "generic" CPU as well: it should only support the
base ISA (and binutils agrees).

Also unify the MC tests into crc.s and arm64-crc32.s

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302077 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 20:33:52 +00:00
Zachary Turner
2a1f47ab11 Remove unused private field.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302069 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 19:42:06 +00:00
Greg Clayton
40ec86bcc2 Break verification down into smaller functions to keep code clean.
Adrian requested that we break things down to make things clean in the DWARFVerifier. This patch breaks everything down into nice individual functions and cleans up the code quite a bit and prepares us for the next round of verifiers.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302062 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 18:25:46 +00:00
Reid Kleckner
a82b376f69 [IR] Abstract away ArgNo+1 attribute indexing as much as possible
Summary:
Do three things to help with that:
- Add AttributeList::FirstArgIndex, which is an enumerator currently set
  to 1. It allows us to change the indexing scheme with fewer changes.
- Add addParamAttr/removeParamAttr. This just shortens addAttribute call
  sites that would otherwise need to spell out FirstArgIndex.
- Remove some attribute-specific getters and setters from Function that
  take attribute list indices.  Most of these were only used from
  BuildLibCalls, and doesNotAlias was only used to test or set if the
  return value is malloc-like.

I'm happy to split the patch, but I think they are probably easier to
review when taken together.

This patch should be NFC, but it sets the stage to change the indexing
scheme to this, which is more convenient when indexing into an array:
  0: func attrs
  1: retattrs
  2...: arg attrs

Reviewers: chandlerc, pete, javed.absar

Subscribers: david2050, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302060 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 18:17:31 +00:00
Davide Italiano
c59f00f5e0 [CodeView] Remove unused private field. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302056 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 17:37:35 +00:00
Zachary Turner
ff94599664 [CodeView] Use actual strings for dealing with checksums and lines.
The raw CodeView format references strings by "offsets", but it's
confusing what table the offset refers to.  In the case of line
number information, it's an offset into a buffer of records,
and an indirection is required to get another offset into a
different table to find the final string.  And in the case of
checksum information, there is no indirection, and the offset
refers directly to the location of the string in another buffer.

This would be less confusing if we always just referred to the
strings by their value, and have the library be smart enough
to correctly resolve the offsets on its own from the right
location.

This patch makes that possible.  When either reading or writing,
all the user deals with are strings, and the library does the
appropriate translations behind the scenes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302053 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 17:11:40 +00:00
Zachary Turner
f393f97e65 [llvm-readobj] Update readobj to re-use parsing code.
llvm-readobj hand rolls some CodeView parsing code for string
tables, so this patch updates it to re-use some of the newly
introduced parsing code in LLVMDebugInfoCodeView.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302052 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 17:11:11 +00:00
Greg Clayton
c8e3032271 Create DWARFVerifier.cpp and .h and move all DWARF verification code over into it.
Adrian requested we create a DWARFVerifier.cpp file to contain all of the DWARF verification stuff. This change simply moves the functionality over into DWARFVerifier.h and DWARFVerifier.cpp, renames the DWARFVerifier methods to start with lower case, and switches DWARFContext.cpp over to using the new functionality.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302044 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 16:02:29 +00:00
Zachary Turner
6b4b26a1a7 Resubmit r301986 and r301987 "Add codeview::StringTable"
This was reverted due to a "missing" file, but in reality
what happened was that I renamed a file, and then due to
a merge conflict both the old file and the new file got
added to the repository.  This led to an unused cpp file
being in the repo and not referenced by any CMakeLists.txt
but #including a .h file that wasn't in the repo.  In an
even more unfortunate coincidence, CMake didn't report the
unused cpp file because it was in a subdirectory of the
folder with the CMakeLists.txt, and not in the same directory
as any CMakeLists.txt.

The presence of the unused file was then breaking certain
tools that determine file lists by globbing rather than
by what's specified in CMakeLists.txt

In any case, the fix is to just remove the unused file from
the patch set.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302042 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 15:58:37 +00:00
Simon Pilgrim
9226f72364 [X86][LWP] Add llvm support for LWP instructions (reapplied).
This patch adds support for the the LightWeight Profiling (LWP) instructions which are available on all AMD Bulldozer class CPUs (bdver1 to bdver4).

Reapplied - this time without changing line endings of existing files.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302041 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 15:51:39 +00:00
Craig Topper
52bc9d9102 [APInt] Give the value union a name so we can remove assumptions on VAL being the larger member
Currently several places assume the VAL member is always at least the same size as pVal. In particular for a memcpy in the move assignment operator. While this is a true assumption, it isn't good practice to assume this.

This patch gives the union a name so we can write the memcpy in terms of the union itself. This also adds a similar memcpy to the move constructor where we previously just copied using VAL directly.

This patch is mostly just a mechanical addition of the U in front of VAL and pVAL everywhere. But several constructors had to be modified since we can't directly initializer a field of named union from the initializer list.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302040 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 15:46:24 +00:00
Simon Pilgrim
dad8f545ae Revert rL302028 due to accidental line ending changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302038 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 15:42:29 +00:00
Simon Pilgrim
0766da9258 [X86][LWP] Add llvm support for LWP instructions.
This patch adds support for the the LightWeight Profiling (LWP) instructions which are available on all AMD Bulldozer class CPUs (bdver1 to bdver4).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302028 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 15:18:34 +00:00
Elad Cohen
ea59a24717 Support arbitrary address space pointers in masked gather/scatter intrinsics.
Fixes PR31789 - When loop-vectorize tries to use these intrinsics for a
non-default address space pointer we fail with a "Calling a function with a
bad singature!" assertion. This patch solves this by adding the 'vector of
pointers' argument as an overloaded type which will determine the address
space.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302018 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 12:28:54 +00:00
Daniel Jasper
5d9d83fb55 Revert r301986 (and subsequent r301987).
The patch is failing to add StringTableStreamBuilder.h, but that isn't
even discovered because the corresponding StringTableStreamBuilder.cpp
isn't added to any CMakeLists.txt file and thus never built. I think
this patch is just incomplete.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302002 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 07:29:25 +00:00
Zachary Turner
d947f15959 Fix use after free in BinaryStream library.
This was reported by the ASAN bot, and it turned out to be
a fairly fundamental problem with the design of VarStreamArray
and the way it passes context information to the extractor.

The fix was cumbersome, and I'm not entirely pleased with it,
so I plan to revisit this design in the future when I'm not
pressed to get the bots green again.  For now, this fixes
the issue by storing the context information by value instead
of by reference, and introduces some impossibly-confusing
template magic to make things "work".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301999 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 05:34:00 +00:00
Matt Arsenault
921f454dae Replace hardcoded intrinsic list with speculatable attribute.
No change in which intrinsics should be speculated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301995 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 02:26:10 +00:00
Tim Shen
85fd68bf82 [PowerPC, DAGCombiner] Fold a << (b % (sizeof(a) * 8)) back to a single instruction
Summary:
This is the corresponding llvm change to D28037 to ensure no performance
regression.

Reviewers: bogner, kbarton, hfinkel, iteratee, echristo

Subscribers: nemanjai, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301990 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 00:07:02 +00:00
Zachary Turner
288180ac40 Make codeview::StringTable.
Previously we had knowledge of how to serialize and deserialize
a string table inside of DebugInfo/PDB, but the string table
that it serializes contains a piece that is actually considered
CodeView and can appear outside of a PDB.  We already have logic
in llvm-readobj and MCCodeView to read and write this format,
so it doesn't make sense to duplicate the logic in DebugInfoPDB
as well.

This patch makes codeview::StringTable (for writing) and
codeview::StringTableRef (for reading), updates DebugInfoPDB
to use these classes for its own writing, and updates llvm-readobj
to additionally use StringTableRef for reading.

It's a bit more difficult to get MCCodeView to use this for
writing, but it's a logical next step.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301986 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 23:36:17 +00:00
Greg Clayton
cfa02bf159 Add line table verification to lldb-dwarfdump --verify
This patch verifies the .debug_line:
- verify all addresses in a line table sequence have ascending addresses
- verify that all line table file indexes are valid

Unit tests added for both cases.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301984 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 22:48:52 +00:00
Reid Kleckner
dac7487074 Re-land r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList"
This time, I fixed, built, and tested clang.

This reverts r301712.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301981 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 22:07:37 +00:00
Joel Jones
845c8c41bc [AArch64] ILP32 Backend Relocation Support
Remove "_NC" suffix and semantics from TLSDESC_LD{64,32}_LO12 and
  TLSDESC_ADD_LO12 relocations
Rearrange ordering in AArch64.def to follow relocation encoding
Fix name:
  R_AARCH64_P32_LD64_GOT_LO12_NC => R_AARCH64_P32_LD32_GOT_LO12_NC
Add support for several "TLS", "TLSGD", and "TLSLD" relocations for
  ILP32
Fix return values from isNonILP32reloc
Add implementations for
  R_AARCH64_ADR_PREL_PG_HI21_NC, R_AARCH64_P32_LD32_GOT_LO12_NC,
  R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC,
  R_AARCH64_P32_TLSDESC_LD32_LO12, R_AARCH64_LD64_GOT_LO12_NC,
  *TLSLD_LDST128_DTPREL_LO12, *TLSLD_LDST128_DTPREL_LO12_NC,
  *TLSLE_LDST128_TPREL_LO12, *TLSLE_LDST128_TPREL_LO12_NC
Modify error messages to give name of equivalent relocation in the
  ABI not being used, along with better checking for non-existent
  requested relocations.
Added assembler support for "pg_hi21_nc"
Relocation definitions added without implementations:
  R_AARCH64_P32_TLSDESC_ADR_PREL21, R_AARCH64_P32_TLSGD_ADR_PREL21,
  R_AARCH64_P32_TLSGD_ADD_LO12_NC, R_AARCH64_P32_TLSLD_ADR_PREL21, 
  R_AARCH64_P32_TLSLD_ADR_PAGE21, R_AARCH64_P32_TLSLD_ADD_LO12_NC,
  R_AARCH64_P32_TLSLD_LD_PREL19, R_AARCH64_P32_TLSDESC_LD_PREL19,
  R_AARCH64_P32_TLSGD_ADR_PAGE21, R_AARCH64_P32_TLS_DTPREL,
  R_AARCH64_P32_TLS_DTPMOD, R_AARCH64_P32_TLS_TPREL,
  R_AARCH64_P32_TLSDESC
Fix encoding:
  R_AARCH64_P32_TLSDESC_ADR_PAGE21

Reviewers: Peter Smith

Patch by: Joel Jones (jjones@cavium.com)

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301980 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 22:01:48 +00:00
Paul Robinson
a6125fe83b [DWARFv5] Parse new line-table header format.
The directory and file tables now have form-based content descriptors.
Parse these and extract the per-directory/file records based on the
descriptors.  For now we support only DW_FORM_string (inline) for the
path names; follow-up work will add support for indirect forms (i.e.,
DW_FORM_strp, strx<N>, and line_strp).

Differential Revision: http://reviews.llvm.org/D32713


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301978 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 21:40:47 +00:00
Greg Clayton
edadbde29a Verify that all references point to actual DIEs in "llvm-dwarfdump --verify"
LTO and other fancy linking previously led to DWARF that contained invalid references. We already validate that CU relative references fall into the CU, and the DW_FORM_ref_addr references fall inside the .debug_info section, but we didn't validate that the references pointed to correct DIE offsets. This new verification will ensure that all references refer to actual DIEs and not an offset in between.

This caught a bug in DWARFUnit::getDIEForOffset() where if you gave it any offset, it would match the DIE that mathes the offset _or_ the next DIE. This has been fixed.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301971 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 20:28:33 +00:00
Krzysztof Parzyszek
b1b2c37305 [Hexagon] Change iconst to emit 27bit relocation
Patch by Colin LeMahieu.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301956 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 18:19:11 +00:00
Krzysztof Parzyszek
e77118b4a6 [Hexagon] Add extenders for GD_PLT_B22_PCREL and LD_PLT_B22_PCREL
Patch by Sid Manning.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301955 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 18:15:33 +00:00
Zachary Turner
479f5fd8d4 Rename pdb::StringTable -> pdb::PDBStringTable.
With the forthcoming codeview::StringTable which a pdb::StringTable
would hold an instance of as one member, this ambiguity becomes
confusing.  Rename to PDBStringTable to avoid this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301948 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 18:00:13 +00:00
Zachary Turner
b712cbbe03 Revert "Remove "_NC" suffix and semantics from TLSDESC_LD{64,32}_LO12 and"
This reverts commit c08155afc5d3230792da2ad30a046a8617735a73.

This is causing undefined symbol errors with some of the constants.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301944 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 17:51:27 +00:00
Paul Robinson
ac4b289dce Make DWARFDebugLine use StringRef for directory/file tables. NFC
Differential Revision: http://reviews.llvm.org/D32728


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301940 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 17:37:32 +00:00
Joel Jones
3322bb7af5 Remove "_NC" suffix and semantics from TLSDESC_LD{64,32}_LO12 and
TLSDESC_ADD_LO12 relocations
Rearrange ordering in AArch64.def to follow relocation encoding
Fix name:
  R_AARCH64_P32_LD64_GOT_LO12_NC => R_AARCH64_P32_LD32_GOT_LO12_NC
Add support for several "TLS", "TLSGD", and "TLSLD" relocations for
  ILP32
Fix return values from isNonILP32reloc
Add implementations for
  R_AARCH64_ADR_PREL_PG_HI21_NC, R_AARCH64_P32_LD32_GOT_LO12_NC,
  R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC,
  R_AARCH64_P32_TLSDESC_LD32_LO12, R_AARCH64_LD64_GOT_LO12_NC,
  *TLSLD_LDST128_DTPREL_LO12, *TLSLD_LDST128_DTPREL_LO12_NC,
  *TLSLE_LDST128_TPREL_LO12, *TLSLE_LDST128_TPREL_LO12_NC
Modify error messages to give name of equivalent relocation in the
  ABI not being used, along with better checking for non-existent
  requested relocations.
Added assembler support for "pg_hi21_nc"
Relocation definitions added without implementations:
  R_AARCH64_P32_TLSDESC_ADR_PREL21, R_AARCH64_P32_TLSGD_ADR_PREL21,
  R_AARCH64_P32_TLSGD_ADD_LO12_NC, R_AARCH64_P32_TLSLD_ADR_PREL21, 
  R_AARCH64_P32_TLSLD_ADR_PAGE21, R_AARCH64_P32_TLSLD_ADD_LO12_NC,
  R_AARCH64_P32_TLSLD_LD_PREL19, R_AARCH64_P32_TLSDESC_LD_PREL19,
  R_AARCH64_P32_TLSGD_ADR_PAGE21, R_AARCH64_P32_TLS_DTPREL,
  R_AARCH64_P32_TLS_DTPMOD, R_AARCH64_P32_TLS_TPREL,
  R_AARCH64_P32_TLSDESC
Fix encoding:
  R_AARCH64_P32_TLSDESC_ADR_PAGE21

Reviewers: Peter Smith

Patch by: Joel Jones (jjones@cavium.com)

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301939 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 17:14:31 +00:00
Matt Arsenault
822c8e2ad2 AMDGPU: Make intrinsics speculatable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301937 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 16:57:44 +00:00
Zachary Turner
e551b3a81e [PDB/CodeView] Read/write codeview inlinee line information.
Previously we wrote line information and file checksum
information, but we did not write information about inlinee
lines and functions.  This patch adds support for that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301936 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 16:56:09 +00:00
Marek Olsak
a2057043bd AMDGPU: Add AMDGPU_HS calling convention
Reviewers: arsenm, nhaehnle

Subscribers: mehdi_amini, kzhuravl, wdng, yaxunl, dstuttard, tpr, llvm-commits, t-tye

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301930 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 15:41:10 +00:00
Rafael Espindola
14c3bbaef3 Add llvm::object::getELFSectionTypeName().
This is motivated by https://reviews.llvm.org/D32488 where I am trying
to add printing of the section type for incompatible sections to LLD
error messages. This patch allows us to use the same code in
llvm-readobj and LLD instead of duplicating the function inside LLD.

Patch by Alexander Richardson!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301921 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 14:04:52 +00:00
Simon Pilgrim
ed79276e6b [SelectionDAG] Improve support for promotion of <1 x fX> floating point argument types (PR31088)
PR31088 demonstrated that we were assuming that only integers require promotion from <1 x iX> types, when in fact float types may require it as well - in this case half floats.

This patch adds support for extension/truncation for both integer and float types.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301910 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 10:33:08 +00:00
Craig Topper
7d66f52694 [APInt] Move APInt::getSplat out of line.
I think this method is probably too complex to be inlined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 06:32:27 +00:00
Craig Topper
382616f0dc [APInt] Move the setBit and clearBit methods inline.
This makes setBit/clearBit more consistent with setBits which is already inlined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301900 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 05:49:40 +00:00
Xinliang David Li
afb34f6072 Refactor callsite cost computation into a helper function /NFC
Makes code more readable. The function will also be used
by the partial inlining's cost analysis.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301899 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 05:38:41 +00:00
Ahmed Bougacha
2f6226dcbd [AArch64] armv8-A doesn't have LSE.
r288279 mistakenly added it to all arches, but it's only available
from v8.1 onwards.

The testcase is awkward, because (I suspect) of PR32873.

Spotted by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301890 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02 00:45:01 +00:00
Paul Robinson
29f8995a43 Stylistic makeover of DWARFDebugLine before working on it. NFC
Rename parameters and locals to CamelCase, doxygenize the header, and
run clang-format on the whole thing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301883 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 23:27:55 +00:00
Zachary Turner
4c78c0e348 [CodeView] Write CodeView line information.
Differential Revision: https://reviews.llvm.org/D32716

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301882 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 23:27:42 +00:00
Davide Italiano
214e3b8d64 [IR] Garbage collect unused variants. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301877 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 23:04:33 +00:00
Matthias Braun
5927be1ab4 MachineFrameInfo: Track whether MaxCallFrameSize is computed yet; NFC
This tracks whether MaxCallFrameSize is computed yet. Ideally we would
assert and fail when the value is queried before it is computed, however
this fails various targets that need to be fixed first.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301851 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 22:32:25 +00:00
Greg Clayton
ce5526513b Adds initial llvm-dwarfdump --verify support with unit tests.
lldb-dwarfdump gets a new "--verify" option that will verify a single file's DWARF debug info and will print out any errors that it finds. It will return an non-zero exit status if verification fails, and a zero exit status if verification succeeds. Adding the --quiet option will suppress any output the STDOUT or STDERR.

The first part of the verify does the following:

- verifies that all CU relative references (DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref4, DW_FORM_ref8, DW_FORM_ref_udata) have valid CU offsets
- verifies that all DW_FORM_ref_addr references have valid .debug_info offsets
- verifies that all DW_AT_ranges attributes have valid .debug_ranges offsets
- verifies that all DW_AT_stmt_list attributes have valid .debug_line offsets
- verifies that all DW_FORM_strp attributes have valid .debug_str offsets

Unit tests were added for each of the above cases.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301844 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 22:07:02 +00:00
Peter Collingbourne
10dbf12dd6 Bitcode: Make the summary reader responsible for merging. NFCI.
This is to prepare for an upcoming change which uses pointers instead of
GUIDs to represent references.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301843 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 22:04:36 +00:00
Craig Topper
4d051558e4 [APInt] In operator!, handle single word case by comparing VAL to 0 directly and handle multiword case by comparing countLeadingZerosSlowCase() to BitWidth.
We were using operator=(0) which implicitly calls countLeadingZeros but only to compare with 64 to determine if we can compare VAL or pVal[0] to uint64_t. By handling the multiword case with countLeadingZerosSlowCase==BitWidth we can prevent a load of pVal[0] from being inserted inline at each call site. This saves a little bit of code size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301842 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 21:56:05 +00:00
Craig Topper
dc229acb5c [APInt] Fix copy/paste mistake in comment for isNullValue. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301838 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 21:16:44 +00:00
Peter Collingbourne
6a2cc4c156 Object: Remove ModuleSummaryIndexObjectFile class.
Differential Revision: https://reviews.llvm.org/D32195

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301832 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 20:42:32 +00:00
Sanjoy Das
30e4179aa1 Use a 2 bit pointer in ValueHandleBase::PrevPair; NFC
This was an omission in r301813.  I had made the supporting changes to
make this happen, but I forgot to actually update the PrevPair
declaration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301817 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 17:36:12 +00:00
Sanjoy Das
2602782e16 Use WeakVH instead of WeakTrackingVH in AliasSetTracker's UnkownInsts
In cases where an instruction (a call site, say) is RAUW'ed with some
other value (this is possible via the `returned` attribute, for
instance), we want the slot in UnknownInsts to point to the original
Instruction we wanted to track, not the value it got replaced by.

Fixes PR32587.

This relands r301426.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301814 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 17:07:56 +00:00
Sanjoy Das
41673c62ec Add a new WeakVH value handle; NFC
This relands r301425.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301813 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 17:07:54 +00:00
Sanjoy Das
399b4d037d Rename WeakVH to WeakTrackingVH; NFC
This relands r301424.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301812 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 17:07:49 +00:00
Zachary Turner
3b718709c4 [PDB/CodeView] Rename some classes.
In preparation for introducing writing capabilities for each of
these classes, I would like to adopt a Foo / FooRef naming
convention, where Foo indicates that the class can manipulate and
serialize Foos, and FooRef indicates that it is an immutable view of
an existing Foo.  In other words, Foo is a writer and FooRef is a
reader.  This patch names some existing readers to conform to the
FooRef convention, while offering no functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301810 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 16:46:39 +00:00
Sanjoy Das
3284bd7d15 Emulate TrackingVH using WeakVH
Summary:
This frees up one slot in the HandleBaseKind enum, which I will use
later to add a new kind of value handle.  The size of the
HandleBaseKind enum is important because we store a HandleBaseKind in
the low two bits of a (in the worst case) 4 byte aligned pointer.

Reviewers: davide, chandlerc

Subscribers: mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301809 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 16:28:58 +00:00
Amara Emerson
195d3fa988 Generalize the specialized flag-carrying SDNodes by moving flags into SDNode.
This removes BinaryWithFlagsSDNode, and flags are now all passed by value.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301803 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 15:17:51 +00:00
Michael Zuckerman
079b067df7 [LLVM][inline-asm] Altmacro absolute expression '%' feature
In this patch, I introduce a new alt macro feature.
This feature adds meaning for the % when using it as a prefix to the calling macro arguments.

In the altmacro mode, the percent sign '%' before an absolute expression convert the expression first to a string. 
As described in the https://sourceware.org/binutils/docs-2.27/as/Altmacro.html
"Expression results as strings
You can write `%expr' to evaluate the expression expr and use the result as a string."

expression assumptions:

1. '%' can only evaluate an absolute expression.
2. Altmacro '%' must be the first character of the evaluated expression.
3. If no '%' is located before the expression, a regular module operation is expected.
4. The result of Absolute Expressions can be only integer.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301797 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 13:20:12 +00:00
Sanjoy Das
21ade9ba1e Rename isKnownNotFullPoison to programUndefinedIfPoison; NFC
Summary:
programUndefinedIfPoison makes more sense, given what the function
does; and I'm about to add a function with a name similar to
isKnownNotFullPoison (so do the rename to avoid confusion).

Reviewers: broune, majnemer, bjarke.roune

Reviewed By: broune

Subscribers: mcrosier, llvm-commits, mzolotukhin

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301776 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 19:41:19 +00:00
Amaury Sechet
bcb9816097 Do not legalize large add with addc/adde, introduce addcarry and do it with uaddo/addcarry
Summary: As per discution on how to get better codegen an large int legalization, it became clear that using a glue for the carry was preventing several desirable optimizations. Passing the carry down as a value allow for more flexibility.

Reviewers: jyknight, nemanjai, mkuper, spatel, RKSimon, zvi, bkramer

Subscribers: igorb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301775 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 19:24:09 +00:00
Guy Blank
0a4ec8f0b2 [MVT] fix typo in size of v1i8 MVT.
Ths issue was found in the review of another patch https://reviews.llvm.org/D32540



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301770 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 12:47:57 +00:00
Craig Topper
f300b51fae [APInt] Remove support for wrapping from APInt::setBits.
This features isn't used anywhere in tree. It's existence seems to be preventing selfhost builds from inlining any of the setBits methods including setLowBits, setHighBits, and setBitsFrom. This is because the code makes the method recursive.

If anyone needs this feature in the future we could consider adding a setBitsWithWrap method. This way only the calls that need it would pay for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301769 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 07:45:01 +00:00
Daniel Sanders
f31ac9d1e8 [globalisel][tablegen] Compute available feature bits correctly.
Summary:
Predicate<> now has a field to indicate how often it must be recomputed.
Currently, there are two frequencies, per-module (RecomputePerFunction==0)
and per-function (RecomputePerFunction==1). Per-function predicates are
currently recomputed more frequently than necessary since the only predicate
in this category is cheap to test. Per-module predicates are now computed in
getSubtargetImpl() while per-function predicates are computed in selectImpl().

Tablegen now manages the PredicateBitset internally. It should only be
necessary to add the required includes.

Also fixed a problem revealed by the test case where
constrainSelectedInstRegOperands() would attempt to tie operands that
BuildMI had already tied.

Reviewers: ab, qcolombet, t.p.northover, rovka, aditya_nandakumar

Reviewed By: rovka

Subscribers: kristof.beyls, igorb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301750 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 17:30:09 +00:00
Craig Topper
8b69610574 [KnownBits] Add methods for determining if the known bits represent a negative/nonnegative number and add methods for changing the negative/nonnegative state
Summary: This patch adds isNegative, isNonNegative for querying whether the sign bit is known. It also adds makeNegative and makeNonNegative for controlling the sign bit.

Reviewers: RKSimon, spatel, davide

Reviewed By: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301747 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 16:43:11 +00:00
Zachary Turner
40d2ca9f43 [llvm-pdbdump] Abstract some of the YAML/Raw printing code.
There is a lot of duplicate code for printing line info between
YAML and the raw output printer.  This introduces a base class
that can be shared between the two, and makes some minor
cleanups in the process.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301728 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 01:13:21 +00:00
Zachary Turner
bb47accc21 [Support] Provide unsafe random access for VarStreamArray.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301716 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 23:29:33 +00:00
Hans Wennborg
dfc1ffb1c9 Revert r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList"
This broke the Clang build. (Clang-side patch missing?)

Original commit message:

> [IR] Make add/remove Attributes use AttrBuilder instead of
> AttributeList
>
> This change cleans up call sites and avoids creating temporary
> AttributeList objects.
>
> NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301712 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 23:01:32 +00:00
Adrian Prantl
841400b968 Remove line and file from DINamespace.
Fixes the issue highlighted in
http://lists.llvm.org/pipermail/cfe-dev/2014-June/037500.html.

The DW_AT_decl_file and DW_AT_decl_line attributes on namespaces can
prevent LLVM from uniquing types that are in the same namespace. They
also don't carry any meaningful information.

rdar://problem/17484998
Differential Revision: https://reviews.llvm.org/D32648

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301706 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 22:25:46 +00:00
Reid Kleckner
fde3916ada [IR] Make add/remove Attributes use AttrBuilder instead of AttributeList
This change cleans up call sites and avoids creating temporary
AttributeList objects.

NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301697 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:48:28 +00:00
Craig Topper
242ed359a8 [APInt] Add an isNullValue method to check for all bits being zero. Use it in a couple internal methods where it makes more sense than isMinValue or !getBoolValue. NFC
I used Null rather than Zero to match the getNullValue method name.

There are some other places outside APInt where isNullValue would be more readable than isMinValue even though they do the same thing. I'll update those in future patches.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301695 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:48:06 +00:00
Sam Clegg
e4f76f4742 [WebAssembly] Add size of section header to data relocation offsets.
Also, add test for data relocations and fix addend to
be signed.

Subscribers: jfb, dschuff

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301690 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:22:38 +00:00
Sam Clegg
649003c411 [WebAssembly] Write initial memory in pages not bytes
Subscribers: jfb, dschuff

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301687 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:12:09 +00:00
Matt Arsenault
8c9ed246f2 TableGen: Add IntrHasSideEffects property for intrinsics
The IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly intrinsic
properties differ from their corresponding LLVM IR attributes by specifying
that the intrinsic, in addition to its memory properties, has no other side
effects.

The IntrHasSideEffects flag used in combination with one of the memory flags
listed above, makes it possible to define an intrinsic such that its
properties at the CodeGen layer match its properties at the IR layer.

Patch by Tom Stellard

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301685 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:01:46 +00:00
Reid Kleckner
52b0228949 Make getParamAlignment use argument numbers
The method is called "get *Param* Alignment", and is only used for
return values exactly once, so it should take argument indices, not
attribute indices.

Avoids confusing code like:
  IsSwiftError = CS->paramHasAttr(ArgIdx, Attribute::SwiftError);
  Alignment  = CS->getParamAlignment(ArgIdx + 1);

Add getRetAlignment to handle the one case in Value.cpp that wants the
return value alignment.

This is a potentially breaking change for out-of-tree backends that do
their own call lowering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301682 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 20:34:27 +00:00
Matt Arsenault
ea376dae25 Add speculatable function attribute
This attribute tells the optimizer that the function may be speculated.

Patch by Tom Stellard

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301680 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 20:25:27 +00:00
Matthias Braun
81de60661c TargetLowering: Add finalizeLowering() function; NFC
Adds a new method finalizeLowering to TargetLoweringBase. This is in
preparation for an upcoming commit.

This function is meant for target specific adjustments to
MachineFrameInfo or register reservations.

Move the freezeRegisters() and the hasCopyImplyingStackAdjustment()
handling into the new function to prove the concept. As an added bonus
GlobalISel no longer missed the hasCopyImplyingStackAdjustment()
handling with this.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301679 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 20:25:05 +00:00
Marek Olsak
007530e1a2 AMDGPU: Add new amdgcn.init.exec intrinsics
v2: More tests, bug fixes, cosmetic changes.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301677 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 20:21:58 +00:00
Daniel Berlin
e2c5126dbb Kill off the old SimplifyInstruction API by converting remaining users.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301673 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 19:55:38 +00:00
Reid Kleckner
331b9af31d Use Argument::hasAttribute and AttributeList::ReturnIndex more
This eliminates many extra 'Idx' induction variables in loops over
arguments in CodeGen/ and Target/. It also reduces the number of places
where we assume that ReturnIndex is 0 and that we should add one to
argument numbers to get the corresponding attribute list index.

NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301666 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 18:37:16 +00:00
Adrian Prantl
4e397d9e33 Cleanup: Use DIExpression::prepend in buildDbgValueForSpill(). (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301665 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 18:30:36 +00:00
Reid Kleckner
a8aa665131 [IR] Delete unused Argument::removeAttr overload
It doesn't make sense to remove an AttributeList from an argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301663 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:58:18 +00:00
Adrian Prantl
2a5bddd278 Clean up DIExpression::prependDIExpr a little. (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301662 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:51:05 +00:00
Peter Collingbourne
b64e9f11ab Bitcode: Do not remove empty summary entries when reading a per-module summary.
This became no longer necessary after D19462 landed, and will be incompatible
with an upcoming change to the summary data structures that changes how we
represent references.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301660 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:41:43 +00:00
Saleem Abdulrasool
b73a15109d IR: fix some doxygen grammar (NFC)
Fix a bit of the doxygen grammar that was off that I noticed while
looking at this file for another issue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301658 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:18:28 +00:00
Craig Topper
78b412f427 [APInt] Add clearSignBit method. Use it and setSignBit in a few places. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301656 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:58:05 +00:00
Tim Northover
0bda850299 CMake: ignore git stderr when trying to sort out revision. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301650 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:06:00 +00:00
Jun Bum Lim
98e89d3bb4 [InlineCost] Improve the cost heuristic for Switch
Summary:
The motivation example is like below which has 13 cases but only 2 distinct targets

```
lor.lhs.false2:                                   ; preds = %if.then
  switch i32 %Status, label %if.then27 [
    i32 -7012, label %if.end35
    i32 -10008, label %if.end35
    i32 -10016, label %if.end35
    i32 15000, label %if.end35
    i32 14013, label %if.end35
    i32 10114, label %if.end35
    i32 10107, label %if.end35
    i32 10105, label %if.end35
    i32 10013, label %if.end35
    i32 10011, label %if.end35
    i32 7008, label %if.end35
    i32 7007, label %if.end35
    i32 5002, label %if.end35
  ]
```
which is compiled into a balanced binary tree like this on AArch64 (similar on X86)

```
.LBB853_9:                              // %lor.lhs.false2
        mov     w8, #10012
        cmp             w19, w8
        b.gt    .LBB853_14
// BB#10:                               // %lor.lhs.false2
        mov     w8, #5001
        cmp             w19, w8
        b.gt    .LBB853_18
// BB#11:                               // %lor.lhs.false2
        mov     w8, #-10016
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#12:                               // %lor.lhs.false2
        mov     w8, #-10008
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#13:                               // %lor.lhs.false2
        mov     w8, #-7012
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_14:                             // %lor.lhs.false2
        mov     w8, #14012
        cmp             w19, w8
        b.gt    .LBB853_21
// BB#15:                               // %lor.lhs.false2
        mov     w8, #-10105
        add             w8, w19, w8
        cmp             w8, #9          // =9
        b.hi    .LBB853_17
// BB#16:                               // %lor.lhs.false2
        orr     w9, wzr, #0x1
        lsl     w8, w9, w8
        mov     w9, #517
        and             w8, w8, w9
        cbnz    w8, .LBB853_23
.LBB853_17:                             // %lor.lhs.false2
        mov     w8, #10013
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_18:                             // %lor.lhs.false2
        mov     w8, #-7007
        add             w8, w19, w8
        cmp             w8, #2          // =2
        b.lo    .LBB853_23
// BB#19:                               // %lor.lhs.false2
        mov     w8, #5002
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#20:                               // %lor.lhs.false2
        mov     w8, #10011
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_21:                             // %lor.lhs.false2
        mov     w8, #14013
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#22:                               // %lor.lhs.false2
        mov     w8, #15000
        cmp             w19, w8
        b.ne    .LBB853_3
```
However, the inline cost model estimates the cost to be linear with the number
of distinct targets and the cost of the above switch is just 2 InstrCosts.
The function containing this switch is then inlined about 900 times.

This change use the general way of switch lowering for the inline heuristic. It
etimate the number of case clusters with the suitability check for a jump table
or bit test. Considering the binary search tree built for the clusters, this
change modifies the model to be linear with the size of the balanced binary
tree. The model is off by default for now :
  -inline-generic-switch-cost=false

This change was originally proposed by Haicheng in D29870.

Reviewers: hans, bmakam, chandlerc, eraman, haicheng, mcrosier

Reviewed By: hans

Subscribers: joerg, aemerson, llvm-commits, rengolin

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301649 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:04:03 +00:00
Andrew Ng
9d0dc96310 [DebugInfo][X86] Improve X86 Optimize LEAs handling of debug values.
This is a follow up to the fix in r298360 to improve the handling of debug
values when redundant LEAs are removed. The fix in r298360 effectively
discarded the debug values. This patch now attempts to preserve the debug
values by using the DWARF DW_OP_stack_value operation via prependDIExpr.

Moved functions appendOffset and prependDIExpr from Local.cpp to
DebugInfoMetadata.cpp and made them available as static member functions of
DIExpression.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301630 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 08:44:30 +00:00
Craig Topper
955683a5c6 [ValueTracking] Convert computeKnownBitsFromRangeMetadata to use KnownBits struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301626 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 06:28:56 +00:00
Craig Topper
8b430f87e6 [SelectionDAG] Use KnownBits struct in DAG's computeKnownBits and simplifyDemandedBits
This patch replaces the separate APInts for KnownZero/KnownOne with a single KnownBits struct. This is similar to what was done to ValueTracking's version recently.

This is largely a mechanical transformation from KnownZero to Known.Zero.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301620 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 05:31:46 +00:00
Saleem Abdulrasool
df4f50c81f COFF Import: expose both symbols
COFF Import libraries which use the obsolete CONSTANT export are
supposed to get two symbols, one with the `_imp_` prefix and one
without.  Ensure that we expose both for iteration.  This is necessary
to fix the librarian with COFF CONSTANT exports.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301614 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 04:29:43 +00:00
Craig Topper
a7fa95c0e5 [APInt] Use inplace shift methods where possible. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301612 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 03:36:24 +00:00
Zachary Turner
a102628313 [llvm-pdbdump] Allow printing only a portion of a stream.
When dumping raw data from a stream, you might know the offset
of a certain record you're interested in, as well as how long
that record is.  Previously, you had to dump the entire stream
and wade through the bytes to find the interesting record.

This patch allows you to specify an offset and length on the
command line, and it will only dump the requested range.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301607 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 00:43:38 +00:00
Evgeniy Stepanov
226bbc3937 [asan] Fix dead stripping of globals on Linux.
Use a combination of !associated, comdat, @llvm.compiler.used and
custom sections to allow dead stripping of globals and their asan
metadata. Sometimes.

Currently this works on LLD, which supports SHF_LINK_ORDER with
sh_link pointing to the associated section.

This also works on BFD, which seems to treat comdats as
all-or-nothing with respect to linker GC. There is a weird quirk
where the "first" global in each link is never GC-ed because of the
section symbols.

At this moment it does not work on Gold (as in the globals are never
stripped).

This is a second re-land of r298158. This time, this feature is
limited to -fdata-sections builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301587 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 20:27:27 +00:00
Zachary Turner
224acd2453 [llvm-readobj] Dump COFF Resources section.
This patch dumps the raw bytes of the .rsrc sections that
are present in COFF object and executable files.  Subsequent
patches will parse this information and dump in a more human
readable format.

Differential Revision: https://reviews.llvm.org/D32463
Patch By: Eric Beckmann

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301578 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 19:38:38 +00:00
Chandler Carruth
1d4cf6e01f [PM/LoopUnswitch] Introduce a new, simpler loop unswitch pass.
Currently, this pass only focuses on *trivial* loop unswitching. At that
reduced problem it remains significantly better than the current loop
unswitch:
- Old pass is worse than cubic complexity. New pass is (I think) linear.
- New pass is much simpler in its design by focusing on full unswitching. (See
  below for details on this).
- New pass doesn't carry state for thresholds between pass iterations.
- New pass doesn't carry state for correctness (both miscompile and
  infloop) between pass iterations.
- New pass produces substantially better code after unswitching.
- New pass can handle more trivial unswitch cases.
- New pass doesn't recompute the dominator tree for the entire function
  and instead incrementally updates it.

I've ported all of the trivial unswitching test cases from the old pass
to the new one to make sure that major functionality isn't lost in the
process. For several of the test cases I've worked to improve the
precision and rigor of the CHECKs, but for many I've just updated them
to handle the new IR produced.

My initial motivation was the fact that the old pass carried state in
very unreliable ways between pass iterations, and these mechansims were
incompatible with the new pass manager. However, I discovered many more
improvements to make along the way.

This pass makes two very significant assumptions that enable most of these
improvements:

1) Focus on *full* unswitching -- that is, completely removing whatever
   control flow construct is being unswitched from the loop. In the case
   of trivial unswitching, this means removing the trivial (exiting)
   edge. In non-trivial unswitching, this means removing the branch or
   switch itself. This is in opposition to *partial* unswitching where
   some part of the unswitched control flow remains in the loop. Partial
   unswitching only really applies to switches and to folded branches.
   These are very similar to full unrolling and partial unrolling. The
   full form is an effective canonicalization, the partial form needs
   a complex cost model, cannot be iterated, isn't canonicalizing, and
   should be a separate pass that runs very late (much like unrolling).

2) Leverage LLVM's Loop machinery to the fullest. The original unswitch
   dates from a time when a great deal of LLVM's loop infrastructure was
   missing, ineffective, and/or unreliable. As a consequence, a lot of
   complexity was added which we no longer need.

With these two overarching principles, I think we can build a fast and
effective unswitcher that fits in well in the new PM and in the
canonicalization pipeline. Some of the remaining functionality around
partial unswitching may not be relevant today (not many test cases or
benchmarks I can find) but if they are I'd like to add support for them
as a separate layer that runs very late in the pipeline.

Purely to make reviewing and introducing this code more manageable, I've
split this into first a trivial-unswitch-only pass and in the next patch
I'll add support for full non-trivial unswitching against a *fixed*
threshold, exactly like full unrolling. I even plan to re-use the
unrolling thresholds, as these are incredibly similar cost tradeoffs:
we're cloning a loop body in order to end up with simplified control
flow. We should only do that when the total growth is reasonably small.

One of the biggest changes with this pass compared to the previous one
is that previously, each individual trivial exiting edge from a switch
was unswitched separately as a branch. Now, we unswitch the entire
switch at once, with cases going to the various destinations. This lets
us unswitch multiple exiting edges in a single operation and also avoids
numerous extremely bad behaviors, where we would introduce 1000s of
branches to test for thousands of possible values, all of which would
take the exact same exit path bypassing the loop. Now we will use
a switch with 1000s of cases that can be efficiently lowered into
a jumptable. This avoids relying on somehow forming a switch out of the
branches or getting horrible code if that fails for any reason.

Another significant change is that this pass actively updates the CFG
based on unswitching. For trivial unswitching, this is actually very
easy because of the definition of loop simplified form. Doing this makes
the code coming out of loop unswitch dramatically more friendly. We
still should run loop-simplifycfg (at the least) after this to clean up,
but it will have to do a lot less work.

Finally, this pass makes much fewer attempts to simplify instructions
based on the unswitch. Something like loop-instsimplify, instcombine, or
GVN can be used to do increasingly powerful simplifications based on the
now dominating predicate. The old simplifications are things that
something like loop-instsimplify should get today or a very, very basic
loop-instcombine could get. Keeping that logic separate is a big
simplifying technique.

Most of the code in this pass that isn't in the old one has to do with
achieving specific goals:
- Updating the dominator tree as we go
- Unswitching all cases in a switch in a single step.

I think it is still shorter than just the trivial unswitching code in
the old pass despite having this functionality.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301576 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 18:45:20 +00:00
Peter Collingbourne
5cb8f64327 cmake: Touch $GIT_DIR/logs/HEAD if it does not already exist.
Apparently some git tools (such as "repo") may not create this file.
Patch by Quentin Neill.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301565 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 17:04:05 +00:00
Frederich Munch
dbf2bf739f Refactor DynamicLibrary so searching for a symbol will have a defined order and
libraries are properly unloaded when llvm_shutdown is called.

Summary:
This was mostly affecting usage of the JIT, where storing the library handles in
a set made iteration unordered/undefined. This lead to disagreement between the
JIT and native code as to what the address and implementation of particularly on
Windows with stdlib functions:

JIT: putenv_s("TEST", "VALUE") // called msvcrt.dll, putenv_s
JIT: getenv("TEST") -> "VALUE" // called msvcrt.dll, getenv
Native: getenv("TEST") -> NULL // called ucrt.dll, getenv

Also fixed is the issue of DynamicLibrary::getPermanentLibrary(0,0) on Windows
not giving priority to the process' symbols as it did on Unix.

Reviewers: chapuni, v.g.vassilev, lhames

Reviewed By: lhames

Subscribers: danalbert, srhines, mgorny, vsk, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301562 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 16:55:24 +00:00
Zachary Turner
2834a6874e [CodeView] Isolate Debug Info Fragments into standalone classes.
Previously parsing of these were all grouped together into a
single master class that could parse any type of debug info
fragment.

With writing forthcoming, the complexity of each individual
fragment is enough to warrant them having their own classes so
that reading and writing of each fragment type can be grouped
together, but isolated from the code for reading and writing
other fragment types.

In doing so, I found a place where parsing code was duplicated
for the FileChecksums fragment, across llvm-readobj and the
CodeView library, and one of the implementations had a bug.
Now that the codepaths are merged, the bug is resolved.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301557 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 16:12:16 +00:00
Zachary Turner
67e6eced9e [Support] Make BinaryStreamArray extractors stateless.
Instead, we now pass a context memeber through the extraction
process.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301556 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 16:11:47 +00:00
Zachary Turner
3220dd07ab Rename some PDB classes.
We have a lot of very similarly named classes related to
dealing with module debug info.  This patch has NFC, it just
renames some classes to be more descriptive (albeit slightly
more to type).  The mapping from old to new class names is as
follows:

   Old          |        New
ModInfo         | DbiModuleDescriptor
ModuleSubstream | ModuleDebugFragment
ModStream       | ModuleDebugStream

With the corresponding Builder classes renamed accordingly.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301555 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 16:11:19 +00:00
Sanjoy Das
9f5bf2cd28 Use accessors for ValueHandleBase::V; NFC
This changes code that touches ValueHandleBase::V to go through
getValPtr and (newly added) setValPtr.  This functionality will be
used later, but also seemed like a generally good cleanup.

I also renamed the field to Val, but that's just to make it obvious
that I fixed all the uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301518 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 06:02:18 +00:00
Rui Ueyama
53d587ee03 Make StringSaver::save less ambiguous.
Previously, an expression such as Saver.save(std::string("foo") + "bar")
didn't compile because there is an ambiguity as to whether the argument
is of const Twine& or StringRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301512 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 03:45:33 +00:00
Ahmed Bougacha
aca7b7d243 [Support] Fix overflow in SLEB128 decoding.
decodeULEB128 was fixed in r216268, but decodeSLEB128 always had the
same issue, which is now exposed in r301369.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301510 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 02:09:44 +00:00
Ahmed Bougacha
89fc611b77 [Support] clang-format LEB128.h. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301509 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 02:09:42 +00:00
Adrian Prantl
9d291ed9ad Turn DISubprogram into a variable-length node.
DISubprogram currently has 10 pointer operands, several of which are
often nullptr. This patch reduces the amount of memory allocated by
DISubprogram by rearranging the operands such that containing type,
template params, and thrown types come last, and are only allocated
when they are non-null (or followed by non-null operands).

This patch also eliminates the entirely unused DisplayName operand.

This saves up to 4 pointer operands per DISubprogram. (I tried
measuring the effect on peak memory usage on an LTO link of an X86
llc, but the results were very noisy).

This reapplies r301498 with an attempted workaround for g++.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301501 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 23:59:52 +00:00
Adrian Prantl
589155c2d7 Revert "Turn DISubprogram into a variable-length node."
This reverts commit r301498 while investigating bot breakage.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301499 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 23:49:30 +00:00
Adrian Prantl
6c938e5225 Turn DISubprogram into a variable-length node.
DISubprogram currently has 10 pointer operands, several of which are
often nullptr. This patch reduces the amount of memory allocated by
DISubprogram by rearranging the operands such that containing type,
template params, and thrown types come last, and are only allocated
when they are non-null (or followed by non-null operands).

This patch also eliminates the entirely unused DisplayName operand.

This saves up to 4 pointer operands per DISubprogram. (I tried
measuring the effect on peak memory usage on an LTO link of an X86
llc, but the results were very noisy).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301498 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 23:44:54 +00:00
Matthias Braun
3e8c96253a MachineFrameInfo.h: Remove unnecessary forward declarations; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301496 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 23:37:04 +00:00
Rui Ueyama
089cd2cb50 Revert r301487: Replace HashString algorithm with xxHash64
This reverts commit r301487 to make buildbots green.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301491 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 23:15:10 +00:00
Adrian Prantl
1bf6297ee8 Add support for DW_TAG_thrown_type.
For Swift we would like to be able to encode the error types that a
function may throw, so the debugger can display them alongside the
function's return value when finish-ing a function.

DWARF defines DW_TAG_thrown_type (intended to be used for C++ throw()
declarations) that is a perfect fit for this purpose. This patch wires
up support for DW_TAG_thrown_type in LLVM by adding a list of thrown
types to DISubprogram.

To offset the cost of the extra pointer, there is a follow-up patch
that turns DISubprogram into a variable-length node.

rdar://problem/29481673

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301489 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 22:56:44 +00:00
Rui Ueyama
2db23b3bbe Replace HashString algorithm with xxHash64
The previous algorithm processed one character at a time, which is very
painful on a modern CPU. Replace it with xxHash64, which both already
exists in the codebase and is fairly fast.

Patch from Scott Smith!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301487 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 22:45:04 +00:00
Eugene Zelenko
f49f90e97b [MC] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301485 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 22:31:39 +00:00
Daniel Berlin
988e599a02 Kill the old Simplify* APIs, leave SimplifyInstruction for the moment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301467 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 20:56:17 +00:00
Craig Topper
58c7fe69d0 [ValueTracking] Introduce a KnownBits struct to wrap the two APInts for computeKnownBits
This patch introduces a new KnownBits struct that wraps the two APInt used by computeKnownBits. This allows us to treat them as more of a unit.

Initially I've just altered the signatures of computeKnownBits and InstCombine's simplifyDemandedBits to pass a KnownBits reference instead of two separate APInt references. I'll do similar to the SelectionDAG version of computeKnownBits/simplifyDemandedBits as a separate patch.

I've added a constructor that allows initializing both APInts to the same bit width with a starting value of 0. This reduces the repeated pattern of initializing both APInts. Once place default constructed the APInts so I added a default constructor for those cases.

Going forward I would like to add more methods that will work on the pairs. For example trunc, zext, and sext occur on both APInts together in several places. We should probably add a clear method that can be used to clear both pieces. Maybe a method to check for conflicting information. A method to return (Zero|One) so we don't write it out everywhere. Maybe a method for (Zero|One).isAllOnesValue() to determine if all bits are known. I'm sure there are many other methods we can come up with.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301432 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 16:39:58 +00:00
Sanjoy Das
263da12ab2 Reverts commit r301424, r301425 and r301426
Commits were:

"Use WeakVH instead of WeakTrackingVH in AliasSetTracker's UnkownInsts"
"Add a new WeakVH value handle; NFC"
"Rename WeakVH to WeakTrackingVH; NFC"

The changes assumed pointers are 8 byte aligned on all architectures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301429 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 16:37:05 +00:00
Sanjoy Das
a7ff6d36af Use WeakVH instead of WeakTrackingVH in AliasSetTracker's UnkownInsts
Summary:
In cases where an instruction (a call site, say) is RAUW'ed with some
other value (this is possible via the `returned` attribute, amongst
other things), we want the slot in UnknownInsts to point to the
original Instruction we wanted to track, not the value it got replaced
by.

Fixes PR32587.

Reviewers: davide

Subscribers: mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301426 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 16:21:02 +00:00
Sanjoy Das
147a8edb1b Add a new WeakVH value handle; NFC
Summary:
WeakVH nulls itself out if the value it was tracking gets deleted, but
it does not track RAUW.

Reviewers: dblaikie, davide

Subscribers: mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301425 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 16:20:59 +00:00
Sanjoy Das
d0cf26e443 Rename WeakVH to WeakTrackingVH; NFC
Summary:
I plan to use WeakVH to mean "nulls itself out on deletion, but does
not track RAUW" in a subsequent commit.

Reviewers: dblaikie, davide

Reviewed By: davide

Subscribers: arsenm, mehdi_amini, mcrosier, mzolotukhin, jfb, llvm-commits, nhaehnle

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301424 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 16:20:52 +00:00
Daniel Berlin
c303d331b4 Convert CVP to use SimplifyQuery version of SimplifyInstruction. Add AssumptionCache, DominatorTree, TLI if available.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301405 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 13:52:13 +00:00
Daniel Berlin
12b3d3d41e InstructionSimplify: Have SimplifyFPBinOp pass FastMathFlags by value, like we do everywhere else
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301380 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 04:10:00 +00:00
Daniel Berlin
32844579d8 InstructionSimplify: End our long national nightmare of ever-growing Simplify* arguments.
Summary:
Expose the internal query structure, start using it.

Note: This is the most minimal change possible i could create.  I have
trivial followups, like fixing the one use of const FastMathFlags &,
the renaming of CtxI to be consistent, etc.

This should be NFC.

Reviewers: majnemer, davide

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301379 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 04:09:56 +00:00
Ahmed Bougacha
3f8d08861b [Support] Avoid UB in sys::fs::perms::operator~. NFC.
This was exposed in r297945 and r301220: the intermediate complement
is a 32-bit value, and casting it to 'perms' invokes UB.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301373 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 00:48:28 +00:00
Sam Clegg
d420e40a96 [WebAssembly] Allow for signed relocation addends
Summary:
Addends are used as offsets to addresses of globals
and can be both positive and negative.  This change
prints libObject in line with the spec and the MC
layer.

Subscribers: jfb, dschuff

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301369 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 00:02:31 +00:00
Zachary Turner
5cec42afa4 [llvm-pdbdump] Allow sorting / filtering by immediate padding
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301358 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-25 20:22:29 +00:00
Zachary Turner
a3ca9305b0 [llvm-pdbdump] Dump File / Line Info to YAML.
We were already parsing and dumping this to the human readable
format, but not to the YAML format.  This does so, in preparation
for reading it in and reconstructing the line information from
YAML.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301357 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-25 20:22:02 +00:00