summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a C++11 ThreadPool implementation in LLVMMehdi Amini2015-12-122-0/+92
| | | | | | | | | | | | | | | | | | This is a very simple implementation of a thread pool using C++11 thread. It accepts any std::function<void()> for asynchronous execution. Individual task can be synchronize using the returned future, or the client can block on the full queue completion. In case LLVM is configured with Threading disabled, it falls back to sequential execution using std::async with launch:deferred. This is intended to support parallelism for ThinLTO processing in linker plugin, but is generic enough for any other uses. Differential Revision: http://reviews.llvm.org/D15464 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 255444
* [Support] Change SaturatingAdd()/SaturatingMultiply() to use pointer for ↵Nathan Slingerland2015-12-091-17/+17
| | | | | | | | | | | | | | | | returning overflow state Summary: Improve SaturatingAdd()/SaturatingMultiply() to use bool * to optionally return overflow result. This should make it clearer that the value is returned at callsites and reduces the size of the implementation. Reviewers: davidxl, silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15219 llvm-svn: 255128
* [Support] Add optional argument to SaturatingAdd() and SaturatingMultiply() ↵Nathan Slingerland2015-11-231-1/+50
| | | | | | | | | | | | | | to indicate that overflow occurred Summary: Adds the ability for callers to detect when saturation occurred on the result of saturating addition/multiplication. Reviewers: davidxl, silvas, rsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14931 llvm-svn: 253921
* [Support] Fix SaturatingMultiply<T>() to be correct (and fast), Re-enable ↵Nathan Slingerland2015-11-231-0/+48
| | | | | | | | | | | | | | | | | | Unit Tests Summary: This change fixes the SaturatingMultiply<T>() function template to not cause undefined behavior with T=uint16_t. Thanks to Richard Smith's contribution, it also no longer requires an integer division. Patch by Richard Smith. Reviewers: silvas, davidxl Subscribers: rsmith, davidxl, llvm-commits Differential Revision: http://reviews.llvm.org/D14845 llvm-svn: 253870
* Revert the revert 253497 and 253539 - These commits aren't the cause of the ↵Daniel Sanders2015-11-201-0/+17
| | | | | | | | clang-cmake-mips failures. Sorry for the noise. llvm-svn: 253662
* Revert 253497 and 253539 to try to fix clang-cmake-mips buildbot.Daniel Sanders2015-11-201-17/+0
| | | | | | | | | | It caused link errors of the form: InstrProfiling.c:(.text.__llvm_profile_instrument_target+0x1c0): undefined reference to `__sync_fetch_and_add_8' We had a network outage at the time of the commit so the first build to show a problem is http://lab.llvm.org:8011/builders/clang-cmake-mips/builds/10827 llvm-svn: 253656
* [Support] Disable SaturatingMultiply() unit test while investigatingNathan Slingerland2015-11-191-19/+0
| | | | | | | | Ubsan detected undefined behavior in the MathExtras SaturatingMultiply test. This change disables the test while it is being investigated. llvm-svn: 253539
* [llvm-profdata] Add SaturatingAdd/SaturatingMultiply Helper Functions (2nd try)Nathan Slingerland2015-11-181-0/+36
| | | | | | | | | | | | | Summary: This change adds MathExtras helper functions for handling unsigned, saturating addition and multiplication. It also updates the instrumentation and sample profile merge implementations to use them. Reviewers: dnovillo, bogner, davidxl Subscribers: davidxl, llvm-commits Differential Revision: http://reviews.llvm.org/D14720 llvm-svn: 253497
* Revert "[llvm-profdata] Add SaturatingAdd/SaturatingMultiply Helper Functions"Nathan Slingerland2015-11-181-48/+0
| | | | | | Not ready for merge. llvm-svn: 253415
* [llvm-profdata] Add SaturatingAdd/SaturatingMultiply Helper FunctionsNathan Slingerland2015-11-181-0/+48
| | | | | | | | | | | | | | | Summary: This change adds MathExtras helper functions for handling unsigned, saturating addition and multiplication. It also updates the instrumentation and sample profile merge implementations to use them. No functional changes. Reviewers: dnovillo, bogner, davidxl Subscribers: davidxl, llvm-commits Differential Revision: http://reviews.llvm.org/D14720 llvm-svn: 253412
* Remove excess white spaceRafael Espindola2015-11-181-6/+0
| | | | llvm-svn: 253408
* Fix -Wunused-function in a non-Win32 buildDavid Blaikie2015-11-171-1/+1
| | | | llvm-svn: 253373
* StringRef-ify some Option APIsDavid Blaikie2015-11-171-6/+6
| | | | | | | | Patch by Eugene Kosov! Differential Revision: http://reviews.llvm.org/D14711 llvm-svn: 253360
* [Support] Tweak path::system_temp_directory() on Windows.Pawel Bylica2015-11-171-0/+70
| | | | | | | | | | | | | | | | | Summary: This patch changes the behavior of path::system_temp_directory() on Windows to be closer to GetTempPath Windows API call. Enforces path separator to be the native one, makes path absolute, etc. GetTempPath is not used directly because of limitations/implementation bugs on Windows 7. Windows specific unit tests are added. Most of them runs in separated process with modified environment variables. This change fixes FileSystemTest.CreateDir unittest that had been failing when run from Unix-like shell on Windows (Unix-like path separator (/) used in env variables). Reviewers: chapuni, rafael, aaron.ballman Subscribers: rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D14231 llvm-svn: 253345
* Add MemoryBufferRef(MemoryBuffer&) constructor.Rafael Espindola2015-11-171-0/+9
| | | | | | patch by Jonathan Anderson! llvm-svn: 253311
* Windows-specific test for sys::path::remove_dots.Mike Aizatsky2015-11-091-0/+13
| | | | | | Differential Revision: http://reviews.llvm.org/D14503 llvm-svn: 252504
* Moving FileManager::removeDotPaths to llvm::sys::path::remove_dotsMike Aizatsky2015-11-091-0/+20
| | | | | | Differential Revision: http://reviews.llvm.org/D14393 llvm-svn: 252499
* Revert r252366: [Support] Use GetTempDir to get the temporary dir path on ↵Pawel Bylica2015-11-061-70/+0
| | | | | | Windows. llvm-svn: 252367
* [Support] Use GetTempDir to get the temporary dir path on Windows.Pawel Bylica2015-11-061-0/+70
| | | | | | | | | | | | | | | Summary: In general GetTempDir follows the same logic as the replaced code: checks env variables TMP, TEMP, USERPROFILE in order. However, it also perform other checks like making separators native (\), making the path absolute, etc. This change fixes FileSystemTest.CreateDir unittest that had been failing when run from Unix-like shell on Windows (Unix-like path separator (/) used in env variables). Reviewers: chapuni, rafael, aaron.ballman Subscribers: rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D14231 llvm-svn: 252366
* Fix unit tests on Windows: handle env vars with non-ASCII chars.Pawel Bylica2015-11-041-38/+70
| | | | | | | | | | | | Summary: On Windows we have to take UTF16 encoded env vars and convert them to UTF8. This patch fixes CopyEnvironment helper function used by process unit tests. Reviewers: yaron.keren Subscribers: yaron.keren, llvm-commits Differential Revision: http://reviews.llvm.org/D14278 llvm-svn: 252039
* [Support] Extend sys::path with user_cache_directory function.Pawel Bylica2015-11-021-0/+29
| | | | | | | | | | | | | | | | | | | | Summary: The new function sys::path::user_cache_directory tries to discover a directory suitable for cache storage for current system user. On Windows and Darwin it returns a path to system-specific user cache directory. On Linux it follows XDG Base Directory Specification, what is: - use non-empty $XDG_CACHE_HOME env var, - use $HOME/.cache. Reviewers: chapuni, aaron.ballman, rafael Subscribers: rafael, aaron.ballman, llvm-commits Differential Revision: http://reviews.llvm.org/D13801 llvm-svn: 251784
* Fix path::home_directory() unit test.Pawel Bylica2015-10-161-8/+12
| | | | | | It turns out that constructing std::string from null pointer is not the very best idea. llvm-svn: 250506
* SupportTests::HomeDirectory: Don't try tests when $HOME is undefined.NAKAMURA Takumi2015-10-161-6/+9
| | | | | | Lit sanitizes env vars. $HOME is not exported in Lit tests. llvm-svn: 250505
* Reformat.NAKAMURA Takumi2015-10-161-1/+1
| | | | llvm-svn: 250504
* Use Windows Vista API to get the user's home directoryPawel Bylica2015-10-161-9/+13
| | | | | | | | | | | | Summary: This patch replaces usage of deprecated SHGetFolderPathW with SHGetKnownFolderPath. The usage of SHGetKnownFolderPath is wrapped to allow queries for other "known" folders in the near future. Reviewers: aaron.ballman, gbedwell Subscribers: chapuni, llvm-commits Differential Revision: http://reviews.llvm.org/D13753 llvm-svn: 250501
* Recommit r250345, it was reverted in r250366 to investigate a bot failure.Manman Ren2015-10-151-0/+41
| | | | | | Our internal bot is still red after r250366. llvm-svn: 250415
* Temporarily revert r250345 to sort out bot failure.Manman Ren2015-10-151-41/+0
| | | | | | | | | | | | | | With r250345 and r250343, we start to observe the following failure when bootstrap clang with lto and pgo: PHI node entries do not match predecessors! %.sroa.029.3.i = phi %"class.llvm::SDNode.13298"* [ null, %30953 ], [ null, %31017 ], [ null, %30998 ], [ null, %_ZN4llvm8dyn_castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERS5_.exit.i.1804 ], [ null, %30975 ], [ null, %30991 ], [ null, %_ZNK4llvm3EVT13getScalarTypeEv.exit.i.1812 ], [ %..sroa.029.0.i, %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit.i.1826 ], !dbg !451895 label %30998 label %_ZNK4llvm3EVTeqES0_.exit19.thread.i LLVM ERROR: Broken function found, compilation aborted! I will re-commit this if the bot does not recover. llvm-svn: 250366
* Update the branch weight metadata in JumpThreading pass.Cong Hou2015-10-141-0/+41
| | | | | | | | | | Currently in JumpThreading pass, the branch weight metadata is not updated after CFG modification. Consider the jump threading on PredBB, BB, and SuccBB. After jump threading, the weight on BB->SuccBB should be adjusted as some of it is contributed by the edge PredBB->BB, which doesn't exist anymore. This patch tries to update the edge weight in metadata on BB->SuccBB by scaling it by 1 - Freq(PredBB->BB) / Freq(BB->SuccBB). This is the third attempt to submit this patch, while the first two led to failures in some FDO tests. After investigation, it is the edge weight normalization that caused those failures. In this patch the edge weight normalization is fixed so that there is no zero weight in the output and the sum of all weights can fit in 32-bit integer. Several unit tests are added. Differential revision: http://reviews.llvm.org/D10979 llvm-svn: 250345
* Add - and -= operators to BlockFrequency using saturating arithmetic.Cong Hou2015-10-121-0/+6
| | | | llvm-svn: 250077
* Fix rename() sometimes failing if another process uses openFileForRead()Greg Bedwell2015-10-122-0/+114
| | | | | | | | | | | | | | | | | | | On Windows, fs::rename() could fail is another process was reading the file at the same time using fs::openFileForRead(). In most cases the user wouldn't notice as fs::rename() will continue to retry for 2000ms. Typically this is enough for the read to complete and a retry to succeed, but if the disk is being it too hard then the response time might be longer than the retry time and the rename would fail with a permission error. Add FILE_SHARE_DELETE to the sharing flags for CreateFileW() in fs::openFileForRead() and try ReplaceFileW() prior to MoveFileExW() in fs::rename(). Based on an initial patch by Edd Dawson! Differential Revision: http://reviews.llvm.org/D13647 llvm-svn: 250046
* Fix another UBSan test error from r248897 and follow on fix r249689Teresa Johnson2015-10-081-0/+84
| | | | | | | While here fix a few more issues with potential overflow and add new tests for these cases. Ensured that test now passes with UBSan. llvm-svn: 249745
* Make test resilient against windows path separators.Benjamin Kramer2015-10-051-0/+1
| | | | llvm-svn: 249320
* [Support] Add a version of fs::make_absolute with a custom CWD.Benjamin Kramer2015-10-051-0/+4
| | | | | | This will be used soon from clang. llvm-svn: 249309
* Add support for sub-byte aligned writes to lib/Support/Endian.hTeresa Johnson2015-09-301-0/+48
| | | | | | | | | | | | | | | Summary: As per Duncan's review for D12536, I extracted the sub-byte bit aligned reading and writing code into lib/Support, and generalized it. Added calls from BackpatchWord. Also added unittests. Reviewers: dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13189 llvm-svn: 248897
* HHVM calling conventions.Maksim Panchenko2015-09-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | HHVM calling convention, hhvmcc, is used by HHVM JIT for functions in translated cache. We currently support LLVM back end to generate code for X86-64 and may support other architectures in the future. In HHVM calling convention any GP register could be used to pass and return values, with the exception of R12 which is reserved for thread-local area and is callee-saved. Other than R12, we always pass RBX and RBP as args, which are our virtual machine's stack pointer and frame pointer respectively. When we enter translation cache via hhvmcc function, we expect the stack to be aligned at 16 bytes, i.e. skewed by 8 bytes as opposed to standard ABI alignment. This affects stack object alignment and stack adjustments for function calls. One extra calling convention, hhvm_ccc, is used to call C++ helpers from HHVM's translation cache. It is almost identical to standard C calling convention with an exception of first argument which is passed in RBP (before we use RDI, RSI, etc.) Differential Revision: http://reviews.llvm.org/D12681 llvm-svn: 248832
* Use fixed-point representation for BranchProbability.Cong Hou2015-09-252-85/+93
| | | | | | | | | | | | | | | | | | | | BranchProbability now is represented by its numerator and denominator in uint32_t type. This patch changes this representation into a fixed point that is represented by the numerator in uint32_t type and a constant denominator 1<<31. This is quite similar to the representation of BlockMass in BlockFrequencyInfoImpl.h. There are several pros and cons of this change: Pros: 1. It uses only a half space of the current one. 2. Some operations are much faster like plus, subtraction, comparison, and scaling by an integer. Cons: 1. Constructing a probability using arbitrary numerator and denominator needs additional calculations. 2. It is a little less precise than before as we use a fixed denominator. For example, 1 - 1/3 may not be exactly identical to 1 / 3 (this will lead to many BranchProbability unit test failures). This should not matter when we only use it for branch probability. If we use it like a rational value for some precise calculations we may need another construct like ValueRatio. One important reason for this change is that we propose to store branch probabilities instead of edge weights in MachineBasicBlock. We also want clients to use probability instead of weight when adding successors to a MBB. The current BranchProbability has more space which may be a concern. Differential revision: http://reviews.llvm.org/D12603 llvm-svn: 248633
* Pass BranchProbability/BlockMass by value instead of const& as they are ↵Cong Hou2015-09-101-1/+1
| | | | | | small. NFC. llvm-svn: 247357
* [ADT] Switch a bunch of places in LLVM that were doing single-characterChandler Carruth2015-09-101-4/+4
| | | | | | | splits to actually use the single character split routine which does less work, and in a debug build is *substantially* faster. llvm-svn: 247245
* Move twice-repeated clang path operation into a new function.Douglas Katzman2015-09-021-0/+10
| | | | | | And make it more robust in the edge case of exactly "./" as input. llvm-svn: 246711
* There is only one saver of strings.Rafael Espindola2015-08-131-1/+1
| | | | llvm-svn: 244854
* Return ErrorOr from FileOutputBuffer::create. NFC.Rafael Espindola2015-08-131-9/+16
| | | | llvm-svn: 244848
* Thread premissions through sys::fs::create_director{y|ies}Frederic Riss2015-08-061-0/+24
| | | | llvm-svn: 244268
* Fix Visual C++ error C2248: Yaron Keren2015-08-061-2/+2
| | | | | | | | | | | | 'llvm::TrailingObjects<`anonymous-namespace'::Class1,short,llvm::NoTrailingTypeArg>::additionalSizeToAlloc' : cannot access protected member declared in class 'llvm::TrailingObjects<`anonymous-namespace'::Class1,short,llvm::NoTrailingTypeArg>' I'm not sure how this compiles with gcc. Aren't protecteded members accessible only with protected or public inheritance? llvm-svn: 244199
* Add a TrailingObjects template class.James Y Knight2015-08-052-0/+148
| | | | | | | | | | This is intended to help support the idiom of a class that has some other objects (or multiple arrays of different types of objects) appended on the end, which is used quite heavily in clang. Differential Revision: http://reviews.llvm.org/D11272 llvm-svn: 244164
* Fix "the the" in comments.Eric Christopher2015-06-191-1/+1
| | | | llvm-svn: 240112
* Revert r239972 (YAML: Assign a value returned by the default constructor to ↵Alex Lorenz2015-06-171-28/+0
| | | | | | | | the value in an optional mapping). This change breaks clang-format tests. llvm-svn: 239976
* YAML: Assign a value returned by the default constructor to the value in an ↵Alex Lorenz2015-06-171-0/+28
| | | | | | | | | | | | | | optional mapping. This commit ensures that a value that's passed into YAML's IO mapOptional method is going to be assigned a value returned by the default constructor for that value's type when the appropriate key is not present in the YAML mapping. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10492 llvm-svn: 239972
* Use std::unique_ptr to manage the DataStreamer in bitcode parsing.Rafael Espindola2015-06-161-4/+5
| | | | | | We were already deleting it, this just makes it explicit. llvm-svn: 239867
* llvm/unittests/Support/Path.cpp: Use <windows.h> instead of <Windows.h>.NAKAMURA Takumi2015-06-161-1/+1
| | | | llvm-svn: 239804
* Don't use std::errc.Rafael Espindola2015-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | As noted on Errc.h: // * std::errc is just marked with is_error_condition_enum. This means that // common patters like AnErrorCode == errc::no_such_file_or_directory take // 4 virtual calls instead of two comparisons. And on some libstdc++ those virtual functions conclude that ------------------------ int main() { std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory); return foo == std::errc::no_such_file_or_directory; } ------------------------- should exit with 0. llvm-svn: 239683
OpenPOWER on IntegriCloud