summaryrefslogtreecommitdiff
path: root/unittests/Support
AgeCommit message (Collapse)AuthorFilesLines
2015-12-21fix leak in a test, make the sanitizer bot greenKostya Serebryany1-1/+2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256179 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-19ThreadPool unittests: do not hold mutex when calling condition_variable:notify()Mehdi Amini1-11/+11
From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256111 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-19[unittests] ThreadPool: Remove redundant loop, NFCVedant Kumar1-4/+2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256097 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-19[unittests] ThreadPool: Guard updates to MainThreadReadyVedant Kumar1-12/+16
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256096 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-19ThreadPool unittest: reimplement concurrency test, deterministically this time.Mehdi Amini1-5/+36
Follow-up to r256056. From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256087 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18Remove possibility of failures to due race in ThreadPool unittestTeresa Johnson1-22/+0
Remove all checks that required main thread to run faster than tasks in ThreadPool, and yields which are now unnecessary. This should fix some bot failures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256056 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18Rewrite the TrailingObjects template to provide two new features:James Y Knight1-4/+34
- Automatic alignment of the base type for the alignment requirements of the trailing types. - Support for an arbitrary numbers of trailing types, instead of only 1 or 2, by using a variadic template implementation. Upcoming commits to clang will take advantage of both of these features. Differential Revision: http://reviews.llvm.org/D12439 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256054 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18BranchProbabilityTest.cpp: Suppress warnings. [-Wsign-compare]NAKAMURA Takumi1-3/+3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-17[BranchProbability] Remove the restriction that known and unknown ↵Cong Hou1-0/+31
probabilities cannot coexist when being normalized. The current BranchProbability::normalizeProbabilities() forbids known and unknown probabilities to coexist in the list. This was once used to help capture probability exceptions but has caused some reported build failures (https://llvm.org/bugs/show_bug.cgi?id=25838). This patch removes this restriction by evenly distributing the complement of the sum of all known probabilities to unknown ones. We could still treat this as an abnormal behavior, but it is better to emit warnings in our future profile validator. Differential revision: http://reviews.llvm.org/D15548 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255934 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15Mark ThreadPool unittests as unsupported on PowerPC64Mehdi Amini1-0/+4
Bots are crashing unexpectingly, see: https://llvm.org/bugs/show_bug.cgi?id=25829 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255633 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15ThreadPool unittest: add a rough mechanism to mark UNSUPPORTED on a given ↵Mehdi Amini1-5/+53
platform From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255632 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15Replace the unit test of BranchProbability::normalizeEdgeWeights() with ↵Cong Hou1-29/+25
BranchProbability::normalizeProbabilities(). BranchProbability::normalizeEdgeWeights() is going to be retired soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255618 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15Fix template parameter pack handling in ThreadPoolTeresa Johnson1-0/+14
Fixes passing of template parameter pack via std::forward and add unittest. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255617 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15Add a C++11 ThreadPool implementation in LLVMMehdi Amini2-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. This is a recommit of r255444 ; trying to workaround a bug in the MSVC 2013 standard library. I think I was hit by: http://connect.microsoft.com/VisualStudio/feedbackdetail/view/791185/std-packaged-task-t-where-t-is-void-or-a-reference-class-are-not-movable Recommit of r255589, trying to please g++ as well. Differential Revision: http://reviews.llvm.org/D15464 From: mehdi_amini <mehdi_amini@91177308-0d34-0410-b5e6-96231b3b80d8> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255593 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15Revert "Add a C++11 ThreadPool implementation in LLVM"Mehdi Amini2-92/+0
This reverts commit r255589. Breaks g++ From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255591 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15Add a C++11 ThreadPool implementation in LLVMMehdi Amini2-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. This is a recommit of r255444 ; trying to workaround a bug in the MSVC 2013 standard library. I think I was hit by: http://connect.microsoft.com/VisualStudio/feedbackdetail/view/791185/std-packaged-task-t-where-t-is-void-or-a-reference-class-are-not-movable Differential Revision: http://reviews.llvm.org/D15464 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255589 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-13Revert r255444.Nico Weber2-92/+0
It doesn't build on Windows and broke the Windows LLD and LLDB bots: http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/27693/steps/build_Lld/logs/stdio http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc/builds/13468/steps/build/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255446 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-12Add a C++11 ThreadPool implementation in LLVMMehdi Amini2-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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255444 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-09[Support] Change SaturatingAdd()/SaturatingMultiply() to use pointer for ↵Nathan Slingerland1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255128 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-23[Support] Add optional argument to SaturatingAdd() and SaturatingMultiply() ↵Nathan Slingerland1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253921 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-23[Support] Fix SaturatingMultiply<T>() to be correct (and fast), Re-enable ↵Nathan Slingerland1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253870 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20Revert the revert 253497 and 253539 - These commits aren't the cause of the ↵Daniel Sanders1-0/+17
clang-cmake-mips failures. Sorry for the noise. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253662 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20Revert 253497 and 253539 to try to fix clang-cmake-mips buildbot.Daniel Sanders1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253656 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-19[Support] Disable SaturatingMultiply() unit test while investigatingNathan Slingerland1-19/+0
Ubsan detected undefined behavior in the MathExtras SaturatingMultiply test. This change disables the test while it is being investigated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253539 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18[llvm-profdata] Add SaturatingAdd/SaturatingMultiply Helper Functions (2nd try)Nathan Slingerland1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253497 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18Revert "[llvm-profdata] Add SaturatingAdd/SaturatingMultiply Helper Functions"Nathan Slingerland1-48/+0
Not ready for merge. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253415 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18[llvm-profdata] Add SaturatingAdd/SaturatingMultiply Helper FunctionsNathan Slingerland1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253412 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18Remove excess white spaceRafael Espindola1-6/+0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253408 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17Fix -Wunused-function in a non-Win32 buildDavid Blaikie1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253373 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17StringRef-ify some Option APIsDavid Blaikie1-6/+6
Patch by Eugene Kosov! Differential Revision: http://reviews.llvm.org/D14711 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253360 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17[Support] Tweak path::system_temp_directory() on Windows.Pawel Bylica1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253345 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17Add MemoryBufferRef(MemoryBuffer&) constructor.Rafael Espindola1-0/+9
patch by Jonathan Anderson! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253311 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-09Windows-specific test for sys::path::remove_dots.Mike Aizatsky1-0/+13
Differential Revision: http://reviews.llvm.org/D14503 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252504 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-09Moving FileManager::removeDotPaths to llvm::sys::path::remove_dotsMike Aizatsky1-0/+20
Differential Revision: http://reviews.llvm.org/D14393 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252499 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06Revert r252366: [Support] Use GetTempDir to get the temporary dir path on ↵Pawel Bylica1-70/+0
Windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252367 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06[Support] Use GetTempDir to get the temporary dir path on Windows.Pawel Bylica1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252366 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-04Fix unit tests on Windows: handle env vars with non-ASCII chars.Pawel Bylica1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252039 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-02[Support] Extend sys::path with user_cache_directory function.Pawel Bylica1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251784 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16Fix path::home_directory() unit test.Pawel Bylica1-8/+12
It turns out that constructing std::string from null pointer is not the very best idea. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250506 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16SupportTests::HomeDirectory: Don't try tests when $HOME is undefined.NAKAMURA Takumi1-6/+9
Lit sanitizes env vars. $HOME is not exported in Lit tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250505 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16Reformat.NAKAMURA Takumi1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250504 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16Use Windows Vista API to get the user's home directoryPawel Bylica1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250501 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-15Recommit r250345, it was reverted in r250366 to investigate a bot failure.Manman Ren1-0/+41
Our internal bot is still red after r250366. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250415 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-15Temporarily revert r250345 to sort out bot failure.Manman Ren1-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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250366 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-14Update the branch weight metadata in JumpThreading pass.Cong Hou1-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250345 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12Add - and -= operators to BlockFrequency using saturating arithmetic.Cong Hou1-0/+6
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250077 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12Fix rename() sometimes failing if another process uses openFileForRead()Greg Bedwell2-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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250046 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08Fix another UBSan test error from r248897 and follow on fix r249689Teresa Johnson1-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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249745 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05Make test resilient against windows path separators.Benjamin Kramer1-0/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249320 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05[Support] Add a version of fs::make_absolute with a custom CWD.Benjamin Kramer1-0/+4
This will be used soon from clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249309 91177308-0d34-0410-b5e6-96231b3b80d8