1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

4158 Commits

Author SHA1 Message Date
Nikolai Bozhenov
52efeb45c3 [Nios2] Target registration
Reviewers: craig.topper, hfinkel, joerg, lattner, zvi

Reviewed By: craig.topper

Subscribers: oren_ben_simhon, igorb, belickim, tvvikram, mgorny, llvm-commits, pavel.v.chupin, DavidKreitzer

Differential Revision: https://reviews.llvm.org/D32669
Patch by AndreiGrischenko <andrei.l.grischenko@intel.com>

llvm-svn: 304144
2017-05-29 09:48:30 +00:00
Galina Kistanova
7e7094daa7 Disabled implicit-fallthrough warnings for ConvertUTF.cpp.
ConvertUTF.cpp has a little dependency on LLVM, and since the code extensively uses fall-through switches,
I prefer disabling the warning for the whole file, rather than adding attributes for each case.

llvm-svn: 304120
2017-05-29 01:34:26 +00:00
Saleem Abdulrasool
34765f36e3 Support: adjust the default obj format for wasm
WebAssemly uses a custom object file format.  For the wasm targets,
default to the `Wasm` object file format.

llvm-svn: 304117
2017-05-29 00:14:57 +00:00
Oren Ben Simhon
a0b50e2d24 [X86] Fixing VPOPCNTDQ feature set lookup.
llvm-svn: 304086
2017-05-28 11:26:11 +00:00
Benjamin Kramer
961a2cb79e Make helper functions static. NFC.
llvm-svn: 304029
2017-05-26 20:09:00 +00:00
Frederich Munch
45b9220e7e Fix the ManagedStatic list ordering when using DynamicLibrary::addPermanentLibrary.
Summary:
r295737 included a fix for leaking libraries loaded via. DynamicLibrary::addPermanentLibrary.
This created a problem where static constructors in a library could insert llvm::ManagedStatic objects before DynamicLibrary would register it's own ManagedStatic, meaning a crash could occur at shutdown.

r301562 exasperated this problem by cleaning up the DynamicLibrary ManagedStatic during llvm_shutdown.

Reviewers: v.g.vassilev, lhames, efriedma

Reviewed By: efriedma

Subscribers: llvm-commits

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

llvm-svn: 304027
2017-05-26 19:43:23 +00:00
Zachary Turner
f8d7ca4856 Make BinaryStreamReader::readCString a bit faster.
Previously it would do a character by character search for a null
terminator, to account for the fact that an arbitrary stream need not
store its data contiguously so you couldn't just do a memchr. However, the
stream API has a function which will return the longest contiguous chunk
without doing a copy, and by using this function we can do a memchr on the
individual chunks. For certain types of streams like data from object
files etc, this is guaranteed to find the null terminator with only a
single memchr, but even with discontiguous streams such as
MappedBlockStream, it's rare that any given string will cross a block
boundary, so even those will almost always be satisfied with a single
memchr.

This optimization is worth a 10-12% reduction in link time (4.2 seconds ->
3.75 seconds)

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

llvm-svn: 303918
2017-05-25 21:12:27 +00:00
Oren Ben Simhon
ff1b128201 [X86] Adding vpopcntd and vpopcntq instructions
AVX512_VPOPCNTDQ is a new feature set that was published by Intel.
The patch represents the LLVM side of the addition of two new intrinsic based instructions (vpopcntd and vpopcntq).

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

llvm-svn: 303858
2017-05-25 13:45:23 +00:00
Craig Topper
bc96c01cc7 [APInt] Use std::end to avoid mentioning the size of a local buffer repeatedly.
llvm-svn: 303726
2017-05-24 07:00:55 +00:00
Galina Kistanova
0f2caec8a0 Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
llvm-svn: 303597
2017-05-23 01:20:52 +00:00
Galina Kistanova
56504c5846 Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
llvm-svn: 303595
2017-05-23 01:07:19 +00:00
Galina Kistanova
8c4e80e401 Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
llvm-svn: 303585
2017-05-22 22:46:31 +00:00
Galina Kistanova
708aeafa8b Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
llvm-svn: 303457
2017-05-19 21:08:28 +00:00
Craig Topper
e1fe9f0a92 [APInt] Add support for dividing or remainder by a uint64_t or int64_t.
Summary:
This patch adds udiv/sdiv/urem/srem/udivrem/sdivrem methods that can divide by a uint64_t. This makes division consistent with all the other arithmetic operations.

This modifies the interface of the divide helper method to work on raw arrays instead of APInts. This way we can pass the uint64_t in for the RHS without wrapping it in an APInt. This required moving all the Quotient and Remainder allocation handling up to the callers. For udiv/urem this was as simple as just creating the Quotient/Remainder with the right size when they were declared. For udivrem we have to rely on reallocate not changing the contents of the variable LHS or RHS is aliased with the Quotient or Remainder APInts. We also have to zero the upper bits of Remainder and Quotient that divide doesn't write to if lhsWords/rhsWords is smaller than the width.

I've update the toString method to use the new udivrem.

Reviewers: hans, dblaikie, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 303431
2017-05-19 16:43:54 +00:00
Akira Hatanaka
c66e3e91c5 [ThinLTO] Do not assert when adding a module with a different but
compatible target triple

Currently, an assertion fails in ThinLTOCodeGenerator::addModule when
the target triple of the module being added doesn't match that of the
one stored in TMBuilder. This patch relaxes the constraint and makes
changes to allow target triples that only differ in their version
numbers on Apple platforms, similarly to what r228999 did.

rdar://problem/30133904

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

llvm-svn: 303326
2017-05-18 03:52:29 +00:00
Zachary Turner
8a52051c62 Add some helpers for manipulating BinaryStreamRefs.
llvm-svn: 303297
2017-05-17 20:42:52 +00:00
Zachary Turner
5fd8290a6c [BinaryStream] Reduce the amount of boiler plate needed to use.
Often you have an array and you just want to use it.  With the current
design, you have to first construct a `BinaryByteStream`, and then create
a `BinaryStreamRef` from it.  Worse, the `BinaryStreamRef` holds a pointer
to the `BinaryByteStream`, so you can't just create a temporary one to
appease the compiler, you have to actually hold onto both the `ArrayRef`
as well as the `BinaryByteStream` *AND* the `BinaryStreamReader` on top of
that.  This makes for very cumbersome code, often requiring one to store a
`BinaryByteStream` in a class just to circumvent this.

At the cost of some added complexity (not exposed to users, but internal
to the library), we can do better than this.  This patch allows us to
construct `BinaryStreamReaders` and `BinaryStreamWriters` directly from
source data (e.g. `StringRef`, `MutableArrayRef<uint8_t>`, etc).  Not only
does this reduce the amount of code you have to type and make it more
obvious how to use it, but it solves real lifetime issues when it's
inconvenient to hold onto a `BinaryByteStream` for a long time.

The additional complexity is in the form of an added layer of indirection.
Whereas before we simply stored a `BinaryStream*` in the ref, we now store
both a `BinaryStream*` **and** a `std::shared_ptr<BinaryStream>`.  When
the user wants to construct a `BinaryStreamRef` directly from an
`ArrayRef` etc, we allocate an internal object that holds ownership over a
`BinaryByteStream` and forwards all calls, and store this in the
`shared_ptr<>`.  This also maintains the ref semantics, as you can copy it
by value and references refer to the same underlying stream -- the one
being held in the object stored in the `shared_ptr`.

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

llvm-svn: 303294
2017-05-17 20:23:31 +00:00
Dimitry Andric
8046961dd3 Revert r303015, because it has the unintended side effect of breaking
driver-mode recognition in clang (this is because the sysctl method
always returns one and only one executable path, even for an executable
with multiple links):

Fix DynamicLibraryTest.cpp on FreeBSD and NetBSD

Summary:

After rL301562, on FreeBSD the DynamicLibrary unittests fail, because
the test uses getMainExecutable("DynamicLibraryTests", Ptr), and since
the path does not contain any slashes, retrieving the main executable
will not work.

Reimplement getMainExecutable() for FreeBSD and NetBSD using sysctl(3),
which is more reliable than fiddling with relative or absolute paths.

Also add retrieval of the original argv[] from the GoogleTest framework,
to use as a fallback for other OSes.

Reviewers: emaste, marsupial, hans, krytarowski

Reviewed By: krytarowski

Subscribers: krytarowski, llvm-commits

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

llvm-svn: 303285
2017-05-17 19:33:10 +00:00
Reid Kleckner
ecbf774b0a Re-land r303274: "[CrashRecovery] Use SEH __try instead of VEH when available"
We have to check gCrashRecoveryEnabled before using __try.

In other words, SEH works too well and we ended up recovering from
crashes in implicit module builds that we weren't supposed to. Only
libclang is supposed to enable CrashRecoveryContext to allow implicit
module builds to crash.

llvm-svn: 303279
2017-05-17 18:16:17 +00:00
Reid Kleckner
82f1302263 Revert "[CrashRecovery] Use SEH __try instead of VEH when available"
This reverts commit r303274, it appears to break some clang tests.

llvm-svn: 303275
2017-05-17 17:15:00 +00:00
Reid Kleckner
febdda5ca0 [CrashRecovery] Use SEH __try instead of VEH when available
Summary:
It avoids problems when other libraries raise exceptions. In particular,
OutputDebugString raises an exception that the debugger is supposed to
catch and suppress. VEH kicks in first right now, and that is entirely
incorrect.

Unfortunately, GCC does not support SEH, so I've kept the old buggy VEH
codepath around. We could fix it with SetUnhandledExceptionFilter, but
that is not per-thread, so a well-behaved library shouldn't set it.

Reviewers: zturner

Subscribers: llvm-commits, mgorny

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

llvm-svn: 303274
2017-05-17 17:02:16 +00:00
Zachary Turner
6362a19363 Workaround for incorrect Win32 header on GCC.
llvm-svn: 303272
2017-05-17 16:39:33 +00:00
Zachary Turner
8a9d6d1444 Fix for compilers with older CRT header libraries.
llvm-svn: 303220
2017-05-16 22:59:34 +00:00
Zachary Turner
25c8e300a2 [Support] Ignore OutputDebugString exceptions in our crash recovery.
Since we use AddVectoredExceptionHandler, we get notified of
every exception that gets raised by a program.  Sometimes these
are not necessarily errors though, and this can be especially
true when linking against a library that we have no control
over, and may raise an exception internally which it intends
to catch.

In particular, the Windows API OutputDebugString does exactly
this.  It raises an exception inside of a __try / __except,
giving the debugger a chance to handle the exception to print
the message to the debug console.

But this doesn't interoperate nicely with our vectored exception
handler, which just sees another exception and decides that we
need to terminate the program.

Add a special case for this so that we ignore ODS exceptions
and continue normally.

Note that a better fix is to simply not use vectored exception
handlers and use SEH instead, but given that MinGW doesn't support
SEH, this is the only solution for MinGW.

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

llvm-svn: 303219
2017-05-16 22:50:32 +00:00
Craig Topper
caecd51865 [APInt] Simplify a for loop initialization based on the fact that 'n' is known to be 1 by an earlier 'if'.
llvm-svn: 303120
2017-05-15 22:01:03 +00:00
Dimitry Andric
ed09e5409d Fix DynamicLibraryTest.cpp on FreeBSD and NetBSD
Summary:

After rL301562, on FreeBSD the DynamicLibrary unittests fail, because
the test uses getMainExecutable("DynamicLibraryTests", Ptr), and since
the path does not contain any slashes, retrieving the main executable
will not work.

Reimplement getMainExecutable() for FreeBSD and NetBSD using sysctl(3),
which is more reliable than fiddling with relative or absolute paths.

Also add retrieval of the original argv[] from the GoogleTest framework,
to use as a fallback for other OSes.

Reviewers: emaste, marsupial, hans, krytarowski

Reviewed By: krytarowski

Subscribers: krytarowski, llvm-commits

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

llvm-svn: 303015
2017-05-14 18:35:38 +00:00
Craig Topper
c58a047c25 [APInt] Use Lo_32/Hi_32/Make_64 in a few more places in the divide code. NFCI
llvm-svn: 302983
2017-05-13 07:14:17 +00:00
Craig Topper
61ff6979de [APInt] Fix typo in comment. NFC
llvm-svn: 302974
2017-05-13 00:35:30 +00:00
Craig Topper
e96d8395f4 [APInt] Add early outs for a division by 1 to udiv/urem/udivrem
We already counted the number of bits in the RHS so its pretty cheap to just check if the RHS is 1.

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

llvm-svn: 302953
2017-05-12 21:45:50 +00:00
Craig Topper
ddcccb1617 [APInt] In udivrem, remember the bit width in a local variable so we don't reread it from the LHS which might be aliased with Quotient or Remainder.
This helped the compiler generate better code for the single word case. It was able to remember that the bit width was still a single word when it created the Remainder APInt and not create code for it possibly being multiword.

llvm-svn: 302952
2017-05-12 21:45:44 +00:00
Craig Topper
44689ecb8f [APInt] Add an assert to check for divide by zero in udivrem. NFC
udiv and urem already had the same assert.

llvm-svn: 302931
2017-05-12 18:19:01 +00:00
Craig Topper
043b32ee18 [APInt] Remove unnecessary checks of rhsWords==1 with lhsWords==1 from udiv and udivrem. NFC
At this point in the code rhsWords is guaranteed to be non-zero and less than or equal to lhsWords. So if lhsWords is 1, rhsWords must also be 1. urem alread had the check removed so this makes all 3 consistent.

llvm-svn: 302930
2017-05-12 18:18:57 +00:00
Craig Topper
5d64cddba6 [APInt] Fix a case where udivrem might delete and create a new allocation instead of reusing the original.
llvm-svn: 302882
2017-05-12 07:21:09 +00:00
Craig Topper
bf05ecc53e [APInt] Add a utility method to change the bit width and storage size of an APInt.
Summary:
This adds a resize method to APInt that manages deleting/allocating storage for an APInt and changes its bit width. Use this to simplify code in copy assignment and divide.

The assignment code in particular was overly complicated. Treating every possible case as a separate implementation. I'm also pretty sure the clearUnusedBits code at the end was unnecessary. Since we always copying whole words from the source APInt. All unused bits should be clear in the source.

Reviewers: hans, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 302863
2017-05-12 01:46:01 +00:00
Craig Topper
0e993cde91 [APInt] Remove an APInt copy from the return of APInt::multiplicativeInverse.
llvm-svn: 302816
2017-05-11 18:40:53 +00:00
Craig Topper
b77e278950 [APInt] Fix typo in comment. NFC
llvm-svn: 302815
2017-05-11 17:57:43 +00:00
Hans Wennborg
50ef7ca1e8 Fix -DLLVM_ENABLE_THREADS=OFF build after r302748
llvm-svn: 302806
2017-05-11 15:32:47 +00:00
Serge Guelton
02363cd9ec Remove spurious cast of nullptr. NFC.
Conversion rules allow automatic casting of nullptr to any pointer type.

llvm-svn: 302780
2017-05-11 08:53:00 +00:00
Craig Topper
c1ef9481dc [APInt] Remove an unneeded extra temporary APInt from toString.
Turns out udivrem can write its output to the same location as one of its inputs so the extra temporary isn't needed.

llvm-svn: 302772
2017-05-11 07:10:43 +00:00
Craig Topper
584e78cfa3 [APInt] Use negate() instead of copying an APInt to negate it and then writing back over the original value.
llvm-svn: 302770
2017-05-11 07:02:04 +00:00
Zachary Turner
138c7f1361 Final (hopefully) fix for the build bots.
This time it actually occurred to me to change the #defines
to actually test the pre-processed out codepath.  Hopefully
this time it works.

llvm-svn: 302752
2017-05-11 00:22:18 +00:00
Zachary Turner
7decf7242d Try again to fix the buildbots.
TaskGroup and Latch need to be in llvm::parallel::detail, not
in llvm::detail.

llvm-svn: 302751
2017-05-11 00:18:52 +00:00
Zachary Turner
d627f7ee19 Fix build errors with Parallel.
llvm-svn: 302749
2017-05-11 00:09:30 +00:00
Zachary Turner
56ea79dd05 [Support] Move Parallel algorithms from LLD to LLVM.
Differential Revision: https://reviews.llvm.org/D33024

llvm-svn: 302748
2017-05-11 00:03:52 +00:00
Craig Topper
ba47d47292 [APInt] Add negate helper method to implement twos complement. Use it to shorten code.
llvm-svn: 302716
2017-05-10 20:01:38 +00:00
Craig Topper
2707aadba1 [APInt] Make toString use udivrem instead of calling the divide helper method directly. Do a better job of reusing allocations while looping. NFCI
This lets toString take advantage of the degenerate case checks in udivrem and is just generally cleaner.

One minor downside of this is that the divisor APInt now needs to be the same size as Tmp which requires an additional allocation. But we were doing a poor job of reusing allocations before so the new code should still be an improvement.

llvm-svn: 302704
2017-05-10 18:15:24 +00:00
Craig Topper
bafd69a316 [APInt] Use uint32_t instead of unsigned for the storage type throughout the divide code. Use Lo_32/Hi_32/Make_64 helpers instead of casts and shifts. NFCI
llvm-svn: 302703
2017-05-10 18:15:20 +00:00
Craig Topper
5f6094a872 [APInt] Use getRawData to slightly simplify some code.
llvm-svn: 302702
2017-05-10 18:15:17 +00:00
Craig Topper
8afca05207 [APInt] Remove check for single word since single word was handled earlier in the function. NFC
llvm-svn: 302701
2017-05-10 18:15:14 +00:00
Craig Topper
2eb1e4752a [APInt] Fix indentation of tcDivide. Combine variable declaration and initialization.
llvm-svn: 302626
2017-05-10 07:50:17 +00:00
Craig Topper
d9eda483c3 [APInt] Use getNumWords function in udiv/urem/udivrem instead of reimplementinging it.
llvm-svn: 302625
2017-05-10 07:50:15 +00:00
Craig Topper
cd4fbccfe2 [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.

llvm-svn: 302551
2017-05-09 16:47:33 +00:00
Craig Topper
d01aa8fcf3 [APInt] Use default constructor instead of explicitly creating a 1-bit APInt in udiv and urem. NFC
The default constructor does the same thing.

llvm-svn: 302487
2017-05-08 23:49:54 +00:00
Craig Topper
06bee7941a [APInt] Remove 'else' after 'return' in udiv and urem. NFC
llvm-svn: 302486
2017-05-08 23:49:49 +00:00
Craig Topper
63b5b25d3d [APInt] Modify tcMultiplyPart's overflow detection to not depend on 'i' from the earlier loop. NFC
The value of 'i' is always the smaller of DstParts and SrcParts so we can just use that fact to write all the code in terms of SrcParts and DstParts.

llvm-svn: 302408
2017-05-08 06:34:41 +00:00
Craig Topper
ee2d9260d4 [APInt] Use std::min instead of writing the same thing with the ternary operator. NFC
llvm-svn: 302407
2017-05-08 06:34:39 +00:00
Craig Topper
649f1ad9b5 [APInt] Remove 'else' after 'return' in tcMultiply methods. NFC
llvm-svn: 302406
2017-05-08 06:34:36 +00:00
Craig Topper
b45ca040d2 [APInt] Take advantage of new operator*=(uint64_t) to remove a temporary APInt.
llvm-svn: 302403
2017-05-08 04:55:12 +00:00
Craig Topper
eb151b0f34 [APInt] Add support for multiplying by a uint64_t.
This makes multiply similar to add, sub, xor, and, and or.

llvm-svn: 302402
2017-05-08 04:55:09 +00:00
Joerg Sonnenberger
8d6ef4a498 If posix_fallocate returns EOPNOTSUPP, fallback to ftruncate.
This can happen at least on NetBSD.

llvm-svn: 302263
2017-05-05 17:55:58 +00:00
Nuno Lopes
8164ea6060 fix build on Cygwin
llvm-svn: 302246
2017-05-05 16:08:22 +00:00
Craig Topper
b6f26d8003 [APInt] Reduce number of allocations involved in multiplying. Reduce worst case multiply size
Currently multiply is implemented in operator*=. Operator* makes a copy and uses operator*= to modify the copy.

Operator*= itself allocates a temporary buffer to hold the multiply result as it computes it. Then copies it to the buffer in *this.

Operator*= attempts to bound the size of the result based on the number of active bits in its inputs. It also has a couple special cases to handle 0 inputs without any memory allocations or multiply operations. The best case is that it calculates a single word regardless of input bit width. The worst case is that it calculates the a 2x input width result and drop the upper bits.

Since operator* uses operator*= it incurs two allocations, one for a copy of *this and one for the temporary allocation. Neither of these allocations are kept after the method operation is done.

The main usage in the backend appears to be ConstantRange::multiply which uses operator* rather than operator*=.

This patch moves the multiply operation to operator* and implements operator*= using it. This avoids the copy in operator*. operator* now allocates a result buffer sized the same width as its inputs no matter what. This buffer will be used as the buffer for the returned APInt. Finally, we reuse tcMultiply to implement the multiply operation. This function is capable of not calculating additional upper words that will be discarded.

This change does lose the special optimizations for the inputs using less words than their size implies. But it also removed the getActiveBits calls from all multiplies. If we think those optimizations are important we could look at providing additional bounds to tcMultiply to limit the computations.

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

llvm-svn: 302171
2017-05-04 17:00:41 +00:00
Ahmed Bougacha
a59429f8b7 [AArch64] Fix variable name ambiguity in r302078.
ArchKind is passed to the function, but it's also a type.

llvm-svn: 302081
2017-05-03 20:51:34 +00:00
Ahmed Bougacha
64c0163225 [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

llvm-svn: 302078
2017-05-03 20:33:58 +00:00
Zachary Turner
28d3fba1b3 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.

llvm-svn: 302042
2017-05-03 15:58:37 +00:00
Simon Pilgrim
77fc2a26c1 [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

llvm-svn: 302041
2017-05-03 15:51:39 +00:00
Craig Topper
356602eddf [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

llvm-svn: 302040
2017-05-03 15:46:24 +00:00
Simon Pilgrim
eaf4f18bdb Revert rL302028 due to accidental line ending changes.
llvm-svn: 302038
2017-05-03 15:42:29 +00:00
Simon Pilgrim
b08b11fc05 [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

llvm-svn: 302028
2017-05-03 15:18:34 +00:00
Alex Lorenz
149d32207b [Triple] Add a "macos" OS type that acts as a synonym for "macosx"
The "macosx" OS type is still the canonical type. In the future "macos" will
become the canonical OS type (but we will still support "macosx").

rdar://27043820

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

llvm-svn: 302011
2017-05-03 10:42:35 +00:00
Daniel Jasper
46c75d6ad5 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.

llvm-svn: 302002
2017-05-03 07:29:25 +00:00
Zachary Turner
fc2ee0d542 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.

llvm-svn: 301986
2017-05-02 23:36:17 +00:00
Paul Robinson
f2738d0659 Make DWARFDebugLine use StringRef for directory/file tables. NFC
Differential Revision: http://reviews.llvm.org/D32728

llvm-svn: 301940
2017-05-02 17:37:32 +00:00
Craig Topper
cf01d68fd0 [APInt] Move APInt::getSplat out of line.
I think this method is probably too complex to be inlined.

llvm-svn: 301901
2017-05-02 06:32:27 +00:00
Craig Topper
d5c44cc185 [APInt] Move the setBit and clearBit methods inline.
This makes setBit/clearBit more consistent with setBits which is already inlined.

llvm-svn: 301900
2017-05-02 05:49:40 +00:00
Gabor Horvath
20f8e4c792 Remove unnecessary conditions as suggested by clang-tidy. NFC
Patch by: Gergely Angeli!

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

llvm-svn: 301807
2017-05-01 16:18:42 +00:00
Dimitry Andric
dd49942793 Include <cstdio> in PrettyStackTrace.cpp, since it uses vsnprintf(3).
llvm-svn: 301760
2017-04-29 23:45:30 +00:00
Craig Topper
566764bb04 [APInt] Use inplace shift methods where possible. NFCI
llvm-svn: 301612
2017-04-28 03:36:24 +00:00
Zachary Turner
3f515460eb [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.

llvm-svn: 301607
2017-04-28 00:43:38 +00:00
Frederich Munch
0cccf42c4a 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

llvm-svn: 301562
2017-04-27 16:55:24 +00:00
Rui Ueyama
f21b94f83c Revert r301487: Replace HashString algorithm with xxHash64
This reverts commit r301487 to make buildbots green.

llvm-svn: 301491
2017-04-26 23:15:10 +00:00
Rui Ueyama
7cdb7b7867 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

llvm-svn: 301487
2017-04-26 22:45:04 +00:00
Frederich Munch
4b689f3d70 Revert "Refactor DynamicLibrary so searching for a symbol will have a defined order"
The i686-mingw32-RA-on-linux bot is still having errors.

This reverts commit r301236.

llvm-svn: 301240
2017-04-24 20:16:01 +00:00
Frederich Munch
9771f2c8f0 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

llvm-svn: 301236
2017-04-24 19:55:16 +00:00
Craig Topper
4b4e200b39 [APInt] Simplify the zext and sext methods
This replaces a hand written copy loop with a call to memcpy for both zext and sext.

For sext, it replaces multiple if/else blocks propagating sign information forward. Now we just do a copy, a sign extension on the last copied word, a memset, and clearUnusedBits.

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

llvm-svn: 301201
2017-04-24 17:37:10 +00:00
Craig Topper
cec9913070 [APInt] Add ashrInPlace method and rewrite ashr to make a copy and then call ashrInPlace.
This patch adds an in place version of ashr to match lshr and shl which were recently added.

I've tried to make this similar to the lshr code with additions to handle the sign extension. I've also tried to do this with less if checks than the current ashr code by sign extending the original result to a word boundary before doing any of the shifting. This removes a lot of the complexity of determining where to fill in sign bits after the shifting.

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

llvm-svn: 301198
2017-04-24 17:18:47 +00:00
Craig Topper
837e80758c [APInt] Fix repeated word in comments. NFC
llvm-svn: 301192
2017-04-24 17:00:22 +00:00
Ismail Donmez
3bfc0de252 Add SUSE vendor
Summary: SUSE's ARM triples end with -gnueabi even though they are hard-float. This requires special handling of SUSE ARM triples. Hence we need a way to differentiate the SUSE as vendor. This CL adds that.

Reviewers: chandlerc, compnerd, echristo, rengolin

Reviewed By: rengolin

Subscribers: aemerson, rengolin, llvm-commits

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

llvm-svn: 301174
2017-04-24 11:18:29 +00:00
Craig Topper
09abb62b5d [APInt] Make behavior of ashr by BitWidth consistent between single and multi word.
Previously single word would always return 0 regardless of the original sign. Multi word would return all 0s or all 1s based on the original sign. Now single word takes into account the sign as well.

llvm-svn: 301159
2017-04-24 05:38:26 +00:00
Frederich Munch
f258c34ec2 Revert "Refactor DynamicLibrary so searching for a symbol will have a defined order.”
The changes are causing the i686-mingw32 build to fail.

This reverts commit r301153, and the changes for a separate warning on i686-mingw32 in r301155  and r301156.

llvm-svn: 301157
2017-04-24 03:33:30 +00:00
Frederich Munch
4c356cc43d Fix warning converting from boolean to pointer introduced in r301153.
This reverts commit r301155, which was incorrect.

llvm-svn: 301156
2017-04-24 03:12:16 +00:00
Frederich Munch
5f12ec7493 Fix warning converting from void* to boolean introduced in r301153.
llvm-svn: 301155
2017-04-24 02:51:40 +00:00
Frederich Munch
f573935fa8 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

llvm-svn: 301153
2017-04-24 02:30:12 +00:00
Craig Topper
976b7b2cf5 [APInt] In sext single word case, use SignExtend64 and let the APInt constructor mask off any excess bits.
The current code is trying to be clever with shifts to avoid needing to clear unused bits. But it looks like the compiler is unable to optimize out the unused bit handling in the APInt constructor. Given this its better to just use SignExtend64 and have more readable code.

llvm-svn: 301133
2017-04-23 17:16:24 +00:00
Renato Golin
74c3c2a375 Revert "[APInt] Fix a few places that use APInt::getRawData to operate within the normal API."
This reverts commit r301105, 4, 3 and 1, as a follow up of the previous
revert, which broke even more bots.

For reference:
Revert "[APInt] Use operator<<= where possible. NFC"
Revert "[APInt] Use operator<<= instead of shl where possible. NFC"
Revert "[APInt] Use ashInPlace where possible."

PR32754.

llvm-svn: 301111
2017-04-23 12:15:30 +00:00
Renato Golin
20621d2f75 Revert "[APInt] Add ashrInPlace method and implement ashr using it. Also fix a bug in the shift by BitWidth handling."
This reverts commit r301094, as it broke all ARM self-hosting bots.

PR32754.

llvm-svn: 301110
2017-04-23 12:02:07 +00:00
Craig Topper
fa57b3748d [APInt] Use operator<<= instead of shl where possible. NFC
llvm-svn: 301103
2017-04-23 05:18:31 +00:00
Craig Topper
b7e531c8fa [APInt] Add ashrInPlace method and implement ashr using it. Also fix a bug in the shift by BitWidth handling.
For single word, shift by BitWidth was always returning 0, but for multiword it was based on original sign. Now single word matches multi word.

llvm-svn: 301094
2017-04-22 22:00:03 +00:00
Craig Topper
0b06a173ec [APInt] Remove unnecessary min with BitWidth from countTrailingOnesSlowCase.
The unused upper bits are guaranteed to be 0 so we don't need to worry about accidentally counting them.

llvm-svn: 301091
2017-04-22 19:59:11 +00:00
Craig Topper
bfdb671218 [APInt] Add WORD_MAX constant and use it instead of UINT64_MAX. NFC
llvm-svn: 301069
2017-04-22 06:31:36 +00:00
Frederich Munch
a5213e6707 [Test commit] Remove extra newline.
llvm-svn: 301046
2017-04-21 21:39:50 +00:00
Craig Topper
e0891c7e01 [APInt] Add compare/compareSigned methods that return -1, 0, 1. Reimplement slt/ult and friends using them
Currently sle and ule have to call slt/ult and eq to get the proper answer. This results in extra code for both calls and additional scans of multiword APInts.

This patch replaces slt/ult with a compareSigned/compare that can return -1, 0, or 1 so we can cover all the comparison functions with a single call.

While I was there I removed the activeBits calls and other checks at the start of the slow part of ult. Both of the activeBits calls potentially scan through each of the APInts separately. I can't imagine that's any better than just scanning them in parallel and doing the compares. Now we just share the code with tcCompare.

These changes seem to be good for about a 7-8k reduction on the size of the opt binary on my local x86-64 build.

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

llvm-svn: 300995
2017-04-21 16:13:15 +00:00
Serguei Katkov
6a3381464c [AsmWriter/APFloat] FP constant printing: Avoid usage of locale dependent snprinf
This should fix the bug https://bugs.llvm.org/show_bug.cgi?id=12906

To print the FP constant AsmWriter does the following:

  1) convert FP value to String (actually using snprintf function which is locale dependent).
  2) Convert String back to FP Value
  3) Compare original and got FP values. If they are not equal just dump as hex.

The problem happens on the 2nd step when APFloat does not expect group delimiter or
fraction delimiter other than period symbol and so on, which can be produced on the
first step if LLVM library is used in an environment with corresponding locale set.

To fix this issue the locale independent APFloat:toString function is used.
However it prints FP values slightly differently than snprintf does. Specifically
it suppress trailing zeros in significant, use capital E and so on.
It results in 117 test failures during make check.
To avoid this I've also updated APFloat.toString a bit to pass make check at least.

Reviewers: sberg, bogner, majnemer, sanjoy, timshen, rnk

Reviewed By: timshen, rnk

Subscribers: rnk, llvm-commits

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

llvm-svn: 300943
2017-04-21 02:52:17 +00:00
Paul Robinson
3707b00913 [DWARF] Versioning for DWARF constants; verify FORMs
Associate the version-when-defined with definitions of standard DWARF
constants.  Identify the "vendor" for DWARF extensions.
Use this information to verify FORMs in .debug_abbrev are defined as
of the DWARF version specified in the associated unit.
Removed two tests that had specified DWARF v1 (which essentially does
not exist).

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

llvm-svn: 300875
2017-04-20 19:16:51 +00:00
Craig Topper
6b149d2ea7 [APInt] Add isSubsetOf method that can check if one APInt is a subset of another without creating temporary APInts
This question comes up in many places in SimplifyDemandedBits. This makes it easy to ask without allocating additional temporary APInts.

The BitVector class provides a similar functionality through its (IMHO badly named) test(const BitVector&) method. Though its output polarity is reversed.

I've provided one example use case in this patch. I plan to do more as a follow up.

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

llvm-svn: 300851
2017-04-20 16:17:13 +00:00
Diana Picus
7d3f6c0293 [ARM] Rename HW div feature to HW div Thumb. NFCI.
The hardware div feature refers only to Thumb, but because of its name
it is tempting to use it to check for hardware division in general,
which may cause problems in ARM mode. See https://reviews.llvm.org/D32005.

This patch adds "Thumb" to its name, to make its scope clear. One
notable place where I haven't made the change is in the feature flag
(used with -mattr), which is still hwdiv. Changing it would also require
changes in a lot of tests, including clang tests, and it doesn't seem
like it's worth the effort.

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

llvm-svn: 300827
2017-04-20 09:38:25 +00:00
Craig Topper
e632e218c3 [APInt] Implement APInt::intersects without creating a temporary APInt in the multiword case
Summary: This is a simple question we should be able to answer without creating a temporary to hold the AND result. We can also get an early out as soon as we find a word that intersects.

Reviewers: RKSimon, hans, spatel, davide

Reviewed By: hans, davide

Subscribers: llvm-commits

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

llvm-svn: 300812
2017-04-20 02:11:27 +00:00
Craig Topper
44c19b8c9a [APInt] Implement operator==(uint64_t) similar to ugt/ult(uint64_t) to remove one of the out of line EqualsSlowCase methods.
llvm-svn: 300799
2017-04-19 23:57:51 +00:00
Craig Topper
23e714e783 [APInt] Move the 'return *this' from the slow cases of assignment operators inline. We should let the compiler see that the fast/slow cases both return *this.
I don't think we chain assignments together very often so this shouldn't matter much.

llvm-svn: 300715
2017-04-19 17:01:58 +00:00
Kristof Beyls
47f9c68a6b [GlobalISel] Support vector-of-pointers in LLT
This fixes PR32471.

As comment 10 on that bug report highlights
(https://bugs.llvm.org//show_bug.cgi?id=32471#c10), there are quite a
few different defendable design tradeoffs that could be made, including
not representing pointers at all in LLT.

I decided to go for representing vector-of-pointer as a concept in LLT,
while keeping the size of the LLT type 64 bits (this is an increase from
48 bits before). My rationale for keeping pointers explicit is that on
some targets probably it's very handy to have the distinction between
pointer and non-pointer (e.g. 68K has a different register bank for
pointers IIRC). If we keep a scalar pointer, it probably is easiest to
also have a vector-of-pointers to keep LLT relatively conceptually clean
and orthogonal, while we don't have a very strong reason to break that
orthogonality.  Once we gain more experience on the use of LLT, we can
of course reconsider this direction.

Rejecting vector-of-pointer types in the IRTranslator is also an option
to avoid the crash reported in PR32471, but that is only a very
short-term solution; also needs quite a bit of code tweaks in places,
and is probably fragile. Therefore I didn't consider this the best
option.

llvm-svn: 300664
2017-04-19 07:23:57 +00:00
Xin Tong
dc8dd17743 Allow suppressing host and target info in VersionPrinter
Summary:
VersionPrinter by default outputs information about the Host CPU
and Default target. Printing this information requires linking in
a large amount of data, such as supported target triples as C
strings, which in turn bloats the binary size.

Enable a new CMake option LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO
which controls printing of the host and target info. This allows
the target triple names to be dead-code stripped. This is a nice
win for LLVM clients that wish to minimize their binary size, such
as graphics drivers.

By default this is ON, so there is no change in the default behavior.
Clients who wish to suppress this printing can do so by setting this
option to off via CMake.

A test app on Linux that uses ParseCommandLineOptions() shows a binary
size reduction of 23KB (from 149K to 126K) for a Release build, and 24KB
(from 135K to 111K) in a MinSizeRel build.

Reviewers: klimek, beanz, bogner, chandlerc, compnerd

Reviewed By: compnerd

Patch by pammon (Peter Ammon) !

Subscribers: llvm-commits

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

llvm-svn: 300630
2017-04-19 00:03:36 +00:00
Craig Topper
dab4df0257 [APInt] Inline the single word case of lshrInPlace similar to what we do for <<=.
llvm-svn: 300577
2017-04-18 19:13:27 +00:00
Craig Topper
debb291669 [APInt] Use lshrInPlace to replace lshr where possible
This patch uses lshrInPlace to replace code where the object that lshr is called on is being overwritten with the result.

This adds an lshrInPlace(const APInt &) version as well.

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

llvm-svn: 300566
2017-04-18 17:14:21 +00:00
Kristof Beyls
1c3a629c41 Revert "[GlobalISel] Support vector-of-pointers in LLT"
This reverts r300535 and r300537.
The newly added tests in test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
produces slightly different code between LLVM versions being built with different compilers.
E.g., dependent on the compiler LLVM is built with, either one of the following
can be produced:

remark: <unknown>:0:0: unable to legalize instruction: %vreg0<def>(p0) = G_EXTRACT_VECTOR_ELT %vreg1, %vreg2; (in function: vector_of_pointers_extractelement)
remark: <unknown>:0:0: unable to legalize instruction: %vreg2<def>(p0) = G_EXTRACT_VECTOR_ELT %vreg1, %vreg0; (in function: vector_of_pointers_extractelement)

Non-determinism like this is clearly a bad thing, so reverting this until
I can find and fix the root cause of the non-determinism.

llvm-svn: 300538
2017-04-18 09:26:36 +00:00
Kristof Beyls
e329f3f7e1 Fix gcc build after r300535.
llvm-svn: 300537
2017-04-18 08:47:55 +00:00
Kristof Beyls
507db3264b [GlobalISel] Support vector-of-pointers in LLT
This fixes PR32471.

As comment 10 on that bug report highlights
(https://bugs.llvm.org//show_bug.cgi?id=32471#c10), there are quite a
few different defendable design tradeoffs that could be made, including
not representing pointers at all in LLT.

I decided to go for representing vector-of-pointer as a concept in LLT,
while keeping the size of the LLT type 64 bits (this is an increase from
48 bits before). My rationale for keeping pointers explicit is that on
some targets probably it's very handy to have the distinction between
pointer and non-pointer (e.g. 68K has a different register bank for
pointers IIRC). If we keep a scalar pointer, it probably is easiest to
also have a vector-of-pointers to keep LLT relatively conceptually clean
and orthogonal, while we don't have a very strong reason to break that
orthogonality. Once we gain more experience on the use of LLT, we can
of course reconsider this direction.

Rejecting vector-of-pointer types in the IRTranslator is also an option
to avoid the crash reported in PR32471, but that is only a very
short-term solution; also needs quite a bit of code tweaks in places,
and is probably fragile. Therefore I didn't consider this the best
option.

llvm-svn: 300535
2017-04-18 08:12:45 +00:00
Craig Topper
044fb2ba9d [APInt] Cleanup the reverseBits slow case a little.
Use lshrInPlace. Use single bit extract and operator|=(uint64_t) to avoid a few temporary APInts.

llvm-svn: 300527
2017-04-18 05:02:21 +00:00
Craig Topper
b0d5814eef [APInt] Make operator<<= shift in place. Improve the implementation of tcShiftLeft and use it to implement operator<<=.
llvm-svn: 300526
2017-04-18 04:39:48 +00:00
George Burgess IV
fec4b3628a Add const to a const method. NFC
llvm-svn: 300520
2017-04-18 01:04:05 +00:00
Craig Topper
6607f16ee5 [APInt] Merge the multiword code from lshrInPlace and tcShiftRight into a single implementation
This merges the two different multiword shift right implementations into a single version located in tcShiftRight. lshrInPlace now calls tcShiftRight for the multiword case.

I retained the memmove fast path from lshrInPlace and used a memset for the zeroing. The for loop is basically tcShiftRight's implementation with the zeroing and the intra-shift of 0 removed.

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

llvm-svn: 300503
2017-04-17 21:43:43 +00:00
Craig Topper
eec9b953b2 [APInt] Fix a bug in lshr by a value more than 64 bits above the bit width.
This was throwing an assert because we determined the intra-word shift amount by subtracting the size of the full word shift from the total shift amount. But we failed to account for the fact that we clipped the full word shifts by total words first. To fix this just calculate the intra-word shift as the remainder of dividing by bits per word.

llvm-svn: 300405
2017-04-16 01:03:51 +00:00
Teresa Johnson
afe2130413 [Support] Fix ErrorOr assertion when /proc/cpuinfo doesn't exist.
The ErrorOr should not be dereferenced on the error path.

Patch by Jacob Young

Reviewers: tejohnson

Subscribers: llvm-commits

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

llvm-svn: 300267
2017-04-13 21:51:49 +00:00
Richard Smith
4d5bff7ae0 Remove all allocation and divisions from GreatestCommonDivisor
Switch from Euclid's algorithm to Stein's algorithm for computing GCD. This
avoids the (expensive) APInt division operation in favour of bit operations.
Remove all memory allocation from within the GCD loop by tweaking our `lshr`
implementation so it can operate in-place.

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

llvm-svn: 300252
2017-04-13 20:29:59 +00:00
Craig Topper
ed420c20f5 [APInt] Reorder fields to avoid a hole in the middle of the class
Summary:
APInt is currently implemented with an unsigned BitWidth field first and then a uint_64/pointer union. Due to the 64-bit size of the union there is a hole after the bitwidth.

Putting the union first allows the class to be packed. Making it 12 bytes instead of 16 bytes. An APSInt goes from 20 bytes to 16 bytes.

This shows a 4k reduction on the size of the opt binary on my local x86-64 build. So this enables some other improvement to the code as well.

Reviewers: dblaikie, RKSimon, hans, davide

Reviewed By: davide

Subscribers: davide, llvm-commits

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

llvm-svn: 300171
2017-04-13 04:59:11 +00:00
Craig Topper
8c209cdca5 [APInt] Generalize the implementation of tcIncrement to support adding a full 'word' by introducing tcAddPart. Use this to support tcIncrement, operator++ and operator+=(uint64_t). Do the same for subtract. NFCI.
llvm-svn: 300169
2017-04-13 04:36:06 +00:00
Ed Maste
ea780becd1 Fix detection of backtrace() availability on FreeBSD
On FreeBSD backtrace is not part of libc and depends on libexecinfo
being available. Instead of using manual checks we can use the builtin
CMake module FindBacktrace.cmake to detect availability of backtrace()
in a portable way.

Patch By:	Alex Richardson
Differential Revision:	https://reviews.llvm.org/D27143

llvm-svn: 300062
2017-04-12 13:51:00 +00:00
Yi Kong
7e6ea0bf4f Remove xgene1 from host detection
This is not a supported mcpu tuning option. We should treat it as
"generic" variant.

Also, add record for cortex-a35.

llvm-svn: 300003
2017-04-11 22:39:55 +00:00
Yi Kong
5694f0b69c Implement host CPU detection for AArch64
This shares detection logic with ARM(32), since AArch64 capable CPUs may
also run in 32-bit system mode.

We observe weird /proc/cpuinfo output for MSM8992 and MSM8994, where
they report all CPU cores as one single model, depending on which CPU
core the kernel is running on. As a workaround, we hardcode the known
CPU part name for these SoCs.

For big.LITTLE systems, this patch would only return the part name of
the first core (usually the little core). Proper support will be added
in a follow-up change.

Differential Revision: D31675

llvm-svn: 299458
2017-04-04 19:06:04 +00:00
Craig Topper
8fdfc69d58 [APInt] Make use of whichWord and maskBit to simplify some code. NFC
llvm-svn: 299342
2017-04-02 19:35:18 +00:00
Craig Topper
58e7d0ffdd [APInt] Add a public typedef for the internal type of APInt use it instead of integerPart. Make APINT_BITS_PER_WORD and APINT_WORD_SIZE public.
This patch is one step to attempt to unify the main APInt interface and the tc functions used by APFloat.

This patch adds a WordType to APInt and uses that in all the tc functions. I've added temporary typedefs to APFloat to alias it to integerPart to keep the patch size down. I'll work on removing that in a future patch.

In future patches I hope to reuse the tc functions to implement some of the main APInt functionality.

I may remove APINT_ from BITS_PER_WORD and WORD_SIZE constants so that we don't have the repetitive APInt::APINT_ externally.

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

llvm-svn: 299341
2017-04-02 19:17:22 +00:00
Craig Topper
da5f881e59 [X86] Use tcAdd/tcSubtract to implement the slow case of operator+=/operator-=.
llvm-svn: 299326
2017-04-02 06:59:43 +00:00
Craig Topper
8e1013006a [APInt] Combine declaration and initialization. NFC
llvm-svn: 299325
2017-04-02 06:59:41 +00:00
Craig Topper
65f22f5c12 [APInt] Simplify some code by using operator+=(uint64_t) instead of doing a more complex assignment into a temporary APInt just to use the APInt operator+=.
llvm-svn: 299324
2017-04-02 06:59:38 +00:00
Craig Topper
7ce8f34320 [APInt] Fix typo in comment. NFC
llvm-svn: 299323
2017-04-02 06:59:36 +00:00
Craig Topper
218045c13f [APInt] Use conditional operator to simplify some code. NFC
llvm-svn: 299320
2017-04-01 21:50:10 +00:00
Craig Topper
7700ad04b6 [APInt] Implement flipAllBitsSlowCase with tcComplement. NFCI
llvm-svn: 299319
2017-04-01 21:50:08 +00:00
Craig Topper
0e5c20558b [APInt] Fix indentation. NFC
llvm-svn: 299318
2017-04-01 21:50:06 +00:00
Craig Topper
d23922d24f [APInt] Implement AndAssignSlowCase using tcAnd. Do the same for Or and Xor. NFCI
llvm-svn: 299317
2017-04-01 21:50:03 +00:00
Craig Topper
e205b8c8cd [APInt] Allow GreatestCommonDivisor to take rvalue inputs efficiently. Use moves instead of copies in the loop.
Summary:
GreatestComonDivisor currently makes a copy of both its inputs. Then in the loop we do one move and two copies, plus any allocation the urem call does.

This patch changes it to take its inputs by value so that we can do a move of any rvalue inputs instead of copying. Then in the loop we do 3 move assignments and no copies. This way the only possible allocations we have in the loop is from the urem call.

Reviewers: dblaikie, RKSimon, hans

Reviewed By: dblaikie

Subscribers: llvm-commits

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

llvm-svn: 299314
2017-04-01 20:30:57 +00:00
Craig Topper
2e2c462d24 [APInt] Remove the mul/urem/srem/udiv/sdiv functions from the APIntOps namespace. Replace the few usages with calls to the class methods. NFC
llvm-svn: 299292
2017-04-01 05:08:57 +00:00
Stephen Canon
dc865d22d7 Fix APFloat mod (committing for simonbyrne)
The previous version was prone to intermediate rounding or overflow.

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

llvm-svn: 299256
2017-03-31 20:31:33 +00:00
Craig Topper
25a319fb68 [APInt] Rewrite getLoBits in a way that will do one less memory allocation in the multiword case. Rewrite getHiBits to use the class method version of lshr instead of the one in APIntOps. NFCI
llvm-svn: 299243
2017-03-31 18:48:14 +00:00
Kristof Beyls
2a0353c292 Remove name space pollution from Signals.cpp
llvm-svn: 299224
2017-03-31 14:58:52 +00:00
Kristof Beyls
2f9a65d919 Remove more name space pollution from .inc files
llvm-svn: 299222
2017-03-31 14:26:44 +00:00
Kristof Beyls
1397ecba80 Do not pollute the namespace in a header file.
llvm-svn: 299218
2017-03-31 13:48:21 +00:00
Kristof Beyls
d6adfb4c85 Make naming in Host.h in line with coding standards.
Based on post-commit review comments by Chandler Carruth on
https://reviews.llvm.org/D31236. Thanks!

llvm-svn: 299211
2017-03-31 13:06:40 +00:00
Yaron Keren
7e27a0ae9d Update comment for r299098 per feedback from James Henderson.
llvm-svn: 299207
2017-03-31 12:08:45 +00:00
Kristof Beyls
cbb1a575f1 Do not pollute the namespace in a header file.
llvm-svn: 299203
2017-03-31 12:00:24 +00:00
Yaron Keren
3cbf4715f7 Following r297661, disable dup workaround to disable duplicate STDOUT fd closing and instead directly prevent closing of STD* file descriptors.
We do not want to close STDOUT as there may have been several uses of it
such as the case: llc %s -o=- -pass-remarks-output=- -filetype=asm
which cause multiple closes of STDOUT_FILENO and/or use-after-close of it.
Using dup() in getFD doesn't work as we end up with original STDOUT_FILENO
open anyhow.

reviewed by Rafael Espindola

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

llvm-svn: 299098
2017-03-30 19:30:51 +00:00
Kristof Beyls
cdec0a522a Revert "Make naming in Host.h in line with coding standards."
This reverts r299062, which caused build failures on Windows.
It also reverts the attempts to fix the windows builds in r299064 and r299065.
The introduction of namespace llvm::sys::detail makes MSVC, and seemingly also
mingw, complain about ambiguity with the existing namespace llvm::detail.
E.g.:
C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/MathExtras.h(184): error C2872: 'detail': ambiguous symbol
C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/PointerLikeTypeTraits.h(31): note: could be 'llvm::detail'
C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/Host.h(80): note: or       'llvm::sys::detail'

In r299064 and r299065 I tried to fix these ambiguities, based on the errors
reported in the log files. It seems however that the build stops early when
this kind of error is encountered, and many build-then-fix-iterations on
Windows may be needed to fix this. Therefore reverting r299062 for now to
get the build working again on Windows.

llvm-svn: 299066
2017-03-30 11:06:25 +00:00