summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
Commit message (Collapse)AuthorAgeFilesLines
...
* [ManagedStatic] Avoid putting function pointers in template args.Benjamin Kramer2017-05-291-3/+5
| | | | | | | | This is super awkward, but GCC doesn't let us have template visible when an argument is an inline function and -fvisibility-inlines-hidden is used. llvm-svn: 304175
* Try to work around MSVC being buggy. Attempt #1.Benjamin Kramer2017-05-291-1/+3
| | | | | | error C2971: 'llvm::ManagedStatic': template parameter 'Creator': 'CreateDefaultTimerGroup': a variable with non-static storage duration cannot be used as a non-type argument llvm-svn: 304157
* [Timer] Move DefaultTimerGroup into a ManagedStatic.Benjamin Kramer2017-05-291-3/+4
| | | | | | | | | | | | | This used to be just leaked. r295370 made it use magic statics. This adds a global destructor, which is something we'd like to avoid. It also creates a weird situation where the mutex used by TimerGroup is re-created during global shutdown and leaked. Using a ManagedStatic here is also subtle as it relies on the mutex inside of ManagedStatic to be recursive. I've added a test for that in a previous change. llvm-svn: 304156
* [Nios2] Target registrationNikolai Bozhenov2017-05-291-0/+11
| | | | | | | | | | | | | 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
* Disabled implicit-fallthrough warnings for ConvertUTF.cpp.Galina Kistanova2017-05-291-0/+31
| | | | | | | 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
* Support: adjust the default obj format for wasmSaleem Abdulrasool2017-05-291-2/+4
| | | | | | | WebAssemly uses a custom object file format. For the wasm targets, default to the `Wasm` object file format. llvm-svn: 304117
* [X86] Fixing VPOPCNTDQ feature set lookup.Oren Ben Simhon2017-05-281-1/+1
| | | | llvm-svn: 304086
* Make helper functions static. NFC.Benjamin Kramer2017-05-261-0/+2
| | | | llvm-svn: 304029
* Fix the ManagedStatic list ordering when using ↵Frederich Munch2017-05-261-3/+8
| | | | | | | | | | | | | | | | | | | | 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
* Make BinaryStreamReader::readCString a bit faster.Zachary Turner2017-05-251-13/+14
| | | | | | | | | | | | | | | | | | | | | 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
* [X86] Adding vpopcntd and vpopcntq instructionsOren Ben Simhon2017-05-251-0/+1
| | | | | | | | | 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
* [APInt] Use std::end to avoid mentioning the size of a local buffer repeatedly.Craig Topper2017-05-241-2/+2
| | | | llvm-svn: 303726
* Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.Galina Kistanova2017-05-231-0/+4
| | | | llvm-svn: 303597
* Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.Galina Kistanova2017-05-231-0/+1
| | | | llvm-svn: 303595
* Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.Galina Kistanova2017-05-221-0/+1
| | | | llvm-svn: 303585
* Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.Galina Kistanova2017-05-191-0/+1
| | | | llvm-svn: 303457
* [APInt] Add support for dividing or remainder by a uint64_t or int64_t.Craig Topper2017-05-191-56/+197
| | | | | | | | | | | | | | | | | | | 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
* [ThinLTO] Do not assert when adding a module with a different butAkira Hatanaka2017-05-181-0/+18
| | | | | | | | | | | | | | | | 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
* Add some helpers for manipulating BinaryStreamRefs.Zachary Turner2017-05-171-0/+5
| | | | llvm-svn: 303297
* [BinaryStream] Reduce the amount of boiler plate needed to use.Zachary Turner2017-05-174-4/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert r303015, because it has the unintended side effect of breakingDimitry Andric2017-05-171-24/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Re-land r303274: "[CrashRecovery] Use SEH __try instead of VEH when available"Reid Kleckner2017-05-171-48/+71
| | | | | | | | | | | 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
* Revert "[CrashRecovery] Use SEH __try instead of VEH when available"Reid Kleckner2017-05-171-66/+48
| | | | | | This reverts commit r303274, it appears to break some clang tests. llvm-svn: 303275
* [CrashRecovery] Use SEH __try instead of VEH when availableReid Kleckner2017-05-171-48/+66
| | | | | | | | | | | | | | | | | | | | 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
* Workaround for incorrect Win32 header on GCC.Zachary Turner2017-05-171-6/+4
| | | | llvm-svn: 303272
* Fix for compilers with older CRT header libraries.Zachary Turner2017-05-161-1/+6
| | | | llvm-svn: 303220
* [Support] Ignore OutputDebugString exceptions in our crash recovery.Zachary Turner2017-05-161-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [APInt] Simplify a for loop initialization based on the fact that 'n' is ↵Craig Topper2017-05-151-1/+1
| | | | | | known to be 1 by an earlier 'if'. llvm-svn: 303120
* Fix DynamicLibraryTest.cpp on FreeBSD and NetBSDDimitry Andric2017-05-141-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [APInt] Use Lo_32/Hi_32/Make_64 in a few more places in the divide code. NFCICraig Topper2017-05-131-6/+6
| | | | llvm-svn: 302983
* [APInt] Fix typo in comment. NFCCraig Topper2017-05-131-1/+1
| | | | llvm-svn: 302974
* [APInt] Add early outs for a division by 1 to udiv/urem/udivremCraig Topper2017-05-121-4/+18
| | | | | | | | 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
* [APInt] In udivrem, remember the bit width in a local variable so we don't ↵Craig Topper2017-05-121-4/+5
| | | | | | | | 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
* [APInt] Add an assert to check for divide by zero in udivrem. NFCCraig Topper2017-05-121-0/+1
| | | | | | udiv and urem already had the same assert. llvm-svn: 302931
* [APInt] Remove unnecessary checks of rhsWords==1 with lhsWords==1 from udiv ↵Craig Topper2017-05-121-2/+2
| | | | | | | | 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
* [APInt] Fix a case where udivrem might delete and create a new allocation ↵Craig Topper2017-05-121-2/+5
| | | | | | instead of reusing the original. llvm-svn: 302882
* [APInt] Add a utility method to change the bit width and storage size of an ↵Craig Topper2017-05-121-42/+31
| | | | | | | | | | | | | | | | | | | 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
* [APInt] Remove an APInt copy from the return of APInt::multiplicativeInverse.Craig Topper2017-05-111-1/+4
| | | | llvm-svn: 302816
* [APInt] Fix typo in comment. NFCCraig Topper2017-05-111-1/+1
| | | | llvm-svn: 302815
* Fix -DLLVM_ENABLE_THREADS=OFF build after r302748Hans Wennborg2017-05-111-0/+2
| | | | llvm-svn: 302806
* Remove spurious cast of nullptr. NFC.Serge Guelton2017-05-111-2/+2
| | | | | | Conversion rules allow automatic casting of nullptr to any pointer type. llvm-svn: 302780
* [APInt] Remove an unneeded extra temporary APInt from toString.Craig Topper2017-05-111-5/+1
| | | | | | 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
* [APInt] Use negate() instead of copying an APInt to negate it and then ↵Craig Topper2017-05-111-3/+3
| | | | | | writing back over the original value. llvm-svn: 302770
* Final (hopefully) fix for the build bots.Zachary Turner2017-05-111-1/+1
| | | | | | | | 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
* Try again to fix the buildbots.Zachary Turner2017-05-111-1/+1
| | | | | | | TaskGroup and Latch need to be in llvm::parallel::detail, not in llvm::detail. llvm-svn: 302751
* Fix build errors with Parallel.Zachary Turner2017-05-111-1/+1
| | | | llvm-svn: 302749
* [Support] Move Parallel algorithms from LLD to LLVM.Zachary Turner2017-05-112-0/+137
| | | | | | Differential Revision: https://reviews.llvm.org/D33024 llvm-svn: 302748
* [APInt] Add negate helper method to implement twos complement. Use it to ↵Craig Topper2017-05-101-6/+3
| | | | | | shorten code. llvm-svn: 302716
* [APInt] Make toString use udivrem instead of calling the divide helper ↵Craig Topper2017-05-101-8/+9
| | | | | | | | | | 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
* [APInt] Use uint32_t instead of unsigned for the storage type throughout the ↵Craig Topper2017-05-101-39/+34
| | | | | | divide code. Use Lo_32/Hi_32/Make_64 helpers instead of casts and shifts. NFCI llvm-svn: 302703
OpenPOWER on IntegriCloud