summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/ManagedStatic.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Support] Replace sys::Mutex with their standard equivalents.Benjamin Kramer2019-08-191-6/+5
| | | | | | Only use a recursive mutex if it can be locked recursively. llvm-svn: 369295
* Replace llvm::MutexGuard/UniqueLock with their standard equivalentsBenjamin Kramer2019-08-071-3/+3
| | | | | | | All supported platforms have <mutex> now, so we don't need our own copies any longer. No functionality change intended. llvm-svn: 368149
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove trailing spaceFangrui Song2018-07-301-3/+3
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338293
* [NFC] Remove inaccurate commentJF Bastien2018-05-121-3/+0
| | | | | | | | | | | | | | | Summary: r271558 moved getManagedStaticMutex's mutex from a function-local static to using call_once, but left a comment added in r211424. That comment is now erroneous, remove it. Reviewers: zturner, chandlerc Subscribers: aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D46784 llvm-svn: 332175
* Revamp llvm::once_flag to be closer to std::once_flagKamil Rytarowski2017-02-051-1/+1
| | | | | | | | | | | | | | | | | | | Summary: Make this interface reusable similarly to std::call_once and std::once_flag interface. This makes porting LLDB to NetBSD easier as there was in the original approach a portable way to specify a non-static once_flag. With this change translating std::once_flag to llvm::once_flag is mechanical. Sponsored by <The NetBSD Foundation> Reviewers: mehdi_amini, labath, joerg Reviewed By: mehdi_amini Subscribers: emaste, clayborg Differential Revision: https://reviews.llvm.org/D29566 llvm-svn: 294143
* [ManagedStatic] Reimplement double-checked locking with std::atomic.Benjamin Kramer2016-06-291-12/+3
| | | | | | | | | | | | | This gets rid of the memory fence in the hot path (dereferencing the ManagedStatic), trading for an extra mutex lock in the cold path (when the ManagedStatic was uninitialized). Since this only happens on the first accesses it shouldn't matter much. On strict architectures like x86 this removes any atomic instructions from the hot path. Also remove the tsan annotations, tsan knows how standard atomics work so they should be unnecessary now. llvm-svn: 274131
* [LPM] Reinstate r271781 which reinstated r271652 to replace theChandler Carruth2016-06-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CALL_ONCE_... macro in the legacy pass manager with the new llvm::call_once facility. Nothing changed sicne the last attempt in r271781 which I reverted in r271788. At least one of the failures I saw was spurious, and I want to make sure the other failures are real before I work around them -- they appeared to only effect ppc64le and ppc64be. Original commit message of r271781: ---- [LPM] Reinstate r271652 to replace the CALL_ONCE_... macro in the legacy pass manager with the new llvm::call_once facility. This reverts commit r271657 and re-applies r271652 with a fix to actually work with arguments. In the original version, we just ended up directly calling std::call_once via ADL because of the std::once_flag argument. The llvm::call_once never worked with arguments. Now, llvm::call_once is a variadic template that perfectly forwards everything. As a part of this it had to move to the header and we use a generic functor rather than an explict function pointer. It would be nice to use std::invoke here but we don't have it yet. That means pointer to members won't work here, but that seems a tolerable compromise. I've also tested this by forcing the fallback path, so hopefully it sticks this time. ---- Original commit message of r271652: ---- [LPM] Replace the CALL_ONCE_... macro in the legacy pass manager with the new llvm::call_once facility. This facility matches the standard APIs and when the platform supports it actually directly uses the standard provided functionality. This is both more efficient on some platforms and much more TSan friendly. The only remaining user of the cas_flag and home-rolled atomics is the fallback implementation of call_once. I have a patch that removes them entirely, but it needs a Windows patch to land first. This alone substantially cleans up the macros for the legacy pass manager, and should subsume some of the work Mehdi was doing to clear the path for TSan testing of ThinLTO, a really important step to have reliable upstream testing of ThinLTO in all forms. ---- llvm-svn: 271800
* [LPM] Revert r271781 which was a re-commit of r271652.Chandler Carruth2016-06-041-1/+1
| | | | | | | | | | | | There appears to be a strange exception thrown and crash using call_once on a PPC build bot, and a *really* weird windows link error for GCMetadata.obj. Still need to investigate the cause of both problems. Original change summary: [LPM] Reinstate r271652 to replace the CALL_ONCE_... macro in the legacy pass manager with the new llvm::call_once facility. llvm-svn: 271788
* [LPM] Reinstate r271652 to replace the CALL_ONCE_... macro in the legacyChandler Carruth2016-06-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pass manager with the new llvm::call_once facility. This reverts commit r271657 and re-applies r271652 with a fix to actually work with arguments. In the original version, we just ended up directly calling std::call_once via ADL because of the std::once_flag argument. The llvm::call_once never worked with arguments. Now, llvm::call_once is a variadic template that perfectly forwards everything. As a part of this it had to move to the header and we use a generic functor rather than an explict function pointer. It would be nice to use std::invoke here but we don't have it yet. That means pointer to members won't work here, but that seems a tolerable compromise. I've also tested this by forcing the fallback path, so hopefully it sticks this time. Original commit message: ---- [LPM] Replace the CALL_ONCE_... macro in the legacy pass manager with the new llvm::call_once facility. This facility matches the standard APIs and when the platform supports it actually directly uses the standard provided functionality. This is both more efficient on some platforms and much more TSan friendly. The only remaining user of the cas_flag and home-rolled atomics is the fallback implementation of call_once. I have a patch that removes them entirely, but it needs a Windows patch to land first. This alone substantially cleans up the macros for the legacy pass manager, and should subsume some of the work Mehdi was doing to clear the path for TSan testing of ThinLTO, a really important step to have reliable upstream testing of ThinLTO in all forms. llvm-svn: 271781
* This is yet another attempt to re-instate r220932 as discussed inChandler Carruth2016-06-021-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | D19271. Previous attempt was broken by NetBSD, so in this version I've made the fallback path generic rather than Windows specific and sent both Windows and NetBSD to it. I've also re-formatted the code some, and used an exact clone of the code in PassSupport.h for doing manual call-once using our atomics rather than rolling a new one. If this sticks, we can replace the fallback path for Windows with a Windows-specific implementation that is more reliable. Original commit message: This patch adds an llvm_call_once which is a wrapper around std::call_once on platforms where it is available and devoid of bugs. The patch also migrates the ManagedStatic mutex to be allocated using llvm_call_once. These changes are philosophically equivalent to the changes added in r219638, which were reverted due to a hang on Win32 which was the result of a bug in the Windows implementation of std::call_once. Differential Revision: http://reviews.llvm.org/D5922 llvm-svn: 271558
* Revert "Revert "Revert 220932.": "Removing the static initializer in ↵Mehdi Amini2016-05-141-11/+4
| | | | | | | | | | ManagedStatic.cpp by using llvm_call_once to initialize the ManagedStatic mutex"" This reverts commit r269577. Broke NetBSD, waiting for Kamil to investigate From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 269584
* Revert "Revert 220932.": "Removing the static initializer in ↵Mehdi Amini2016-05-141-4/+11
| | | | | | | | | | | | | | | | | | | | | | ManagedStatic.cpp by using llvm_call_once to initialize the ManagedStatic mutex" This reverts commit r221331 and reinstate r220932 as discussed in D19271. Original commit message was: This patch adds an llvm_call_once which is a wrapper around std::call_once on platforms where it is available and devoid of bugs. The patch also migrates the ManagedStatic mutex to be allocated using llvm_call_once. These changes are philosophically equivalent to the changes added in r219638, which were reverted due to a hang on Win32 which was the result of a bug in the Windows implementation of std::call_once. Differential Revision: http://reviews.llvm.org/D5922 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 269577
* [NFC] Header cleanupMehdi Amini2016-04-181-1/+0
| | | | | | | | | | | | | | Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
* Support: Clean up TSan annotations.Peter Collingbourne2015-08-181-0/+1
| | | | | | | | | | | Remove support for Valgrind-based TSan, which hasn't been maintained for a few years. We now use the TSan annotations only if LLVM is compiled with -fsanitize=thread. We no longer need the weak function definitions as we are guaranteed that our program is linked directly with the TSan runtime. Differential Revision: http://reviews.llvm.org/D12121 llvm-svn: 245374
* Revert 220932.Jiangning Liu2014-11-051-11/+4
| | | | | | | | | Commit 220932 caused crash when building clang-tblgen on aarch64 debian target, so it's blocking all daily tests. The std::call_once implementation in pthread has bug for aarch64 debian. llvm-svn: 221331
* Removing the static initializer in ManagedStatic.cpp by using llvm_call_once ↵Chris Bieneman2014-10-301-4/+11
| | | | | | | | | | | | | | | | | | | to initialize the ManagedStatic mutex. Summary: This patch adds an llvm_call_once which is a wrapper around std::call_once on platforms where it is available and devoid of bugs. The patch also migrates the ManagedStatic mutex to be allocated using llvm_call_once. These changes are philosophically equivalent to the changes added in r219638, which were reverted due to a hang on Win32 which was the result of a bug in the Windows implementation of std::call_once. Reviewers: aaron.ballman, chapuni, chandlerc, rnk Reviewed By: rnk Subscribers: majnemer, llvm-commits Differential Revision: http://reviews.llvm.org/D5922 llvm-svn: 220932
* Revert r219638, (r219640 and r219676), "Removing the static destructor from ↵NAKAMURA Takumi2014-10-141-17/+6
| | | | | | | | ManagedStatic.cpp by controlling the allocation and de-allocation of the mutex." It caused hang-up on msc17 builder, probably deadlock. llvm-svn: 219687
* Removing the static destructor from ManagedStatic.cpp by controlling the ↵Chris Bieneman2014-10-131-6/+17
| | | | | | | | allocation and de-allocation of the mutex. This patch adds a new llvm_call_once function which is used by the ManagedStatic implementation to safely initialize a global to avoid static construction and destruction. llvm-svn: 219638
* Fix the MinGW builder. Apparently std::call_once andZachary Turner2014-06-211-17/+10
| | | | | | | | std::recursive_mutex are not available on MinGW and breaks the builder. Revert to using a function local static and sys::Mutex just to get the tree green until we figure out a better solution. llvm-svn: 211424
* Remove use of removed function, llvm_stop_multithreadingDavid Blaikie2014-06-191-2/+0
| | | | llvm-svn: 211291
* Kill the LLVM global lock.Zachary Turner2014-06-191-3/+20
| | | | | | | | | | | | | | This patch removes the LLVM global lock, and updates all existing users of the global lock to use their own mutex. None of the existing users of the global lock were protecting code that was mutually exclusive with any of the other users of the global lock, so its purpose was not being met. Reviewed by: rnk Differential Revision: http://reviews.llvm.org/D4142 llvm-svn: 211277
* Revert r211066, 211067, 211068, 211069, 211070.Zachary Turner2014-06-161-23/+5
| | | | | | | These were committed accidentally from the wrong branch before having a review sign-off. llvm-svn: 211072
* Kill the LLVM global lock.Zachary Turner2014-06-161-1/+22
| | | | llvm-svn: 211069
* Remove some code churn.Zachary Turner2014-06-161-1/+1
| | | | llvm-svn: 211068
* Remove some more code out into a separate CL.Zachary Turner2014-06-161-3/+1
| | | | llvm-svn: 211067
* Users of the llvm global mutex must now acquire it manually.Zachary Turner2014-06-161-3/+2
| | | | | | This allows the mutex to be acquired in a guarded, RAII fashion. llvm-svn: 211066
* Revert "Remove support for runtime multi-threading."Zachary Turner2014-06-101-2/+4
| | | | | | This reverts revision r210600. llvm-svn: 210603
* Remove support for runtime multi-threading.Zachary Turner2014-06-101-4/+2
| | | | | | | | | | | | | | | | | | | | | This patch removes the functions llvm_start_multithreaded() and llvm_stop_multithreaded(), and changes llvm_is_multithreaded() to return a constant value based on the value of the compile-time definition LLVM_ENABLE_THREADS. Previously, it was possible to have compile-time support for threads on, and runtime support for threads off, in which case certain mutexes were not allocated or ever acquired. Now, if the build is created with threads enabled, mutexes are always acquired. A test before/after patch of compiling a very large TU showed no noticeable performance impact of this change. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D4076 llvm-svn: 210600
* ManagedStatic is never built with a null constructor, remove support for it.David Blaikie2014-04-171-2/+3
| | | | llvm-svn: 206492
* [C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper2014-04-151-1/+1
| | | | | | instead of comparing to nullptr. llvm-svn: 206252
* [C++11] Replace some comparisons with 'nullptr' with simple boolean checks ↵Craig Topper2014-04-091-1/+1
| | | | | | to reduce verbosity. llvm-svn: 205829
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-071-7/+7
| | | | llvm-svn: 205697
* Revert "[C++11] Replace LLVM atomics with std::atomic."Benjamin Kramer2014-03-031-1/+2
| | | | | | | Breaks the MSVC build. DataStream.cpp(44): error C2552: 'llvm::Statistic::Value' : non-aggregates cannot be initialized with initializer list llvm-svn: 202731
* [C++11] Replace LLVM atomics with std::atomic.Benjamin Kramer2014-03-031-2/+1
| | | | | | | | | | | With C++11 we finally have a standardized way to specify atomic operations. Use them to replace the existing custom implemention. Sadly the translation is not entirely trivial as std::atomic allows more fine-grained control over the atomicity. I tried to preserve the old semantics as well as possible. Differential Revision: http://llvm-reviews.chandlerc.com/D2915 llvm-svn: 202730
* Add support for tsan annotations (thread sanitizer, a valgrind-based tool).Nick Lewycky2011-11-141-1/+7
| | | | | | | | | | | | These annotations are disabled entirely when either ENABLE_THREADS is off, or building a release build. When enabled, they add calls to functions with no statements to ManagedStatic's getters. Use these annotations to inform tsan that the race used inside ManagedStatic initialization is actually benign. Thanks to Kostya Serebryany for helping write this patch! llvm-svn: 144567
* Merge System into Support.Michael J. Spencer2010-11-291-1/+1
| | | | llvm-svn: 120298
* Split the thread-related APIs out into their own file, and add a few moreOwen Anderson2009-06-161-20/+4
| | | | | | calls for convenience. llvm-svn: 73512
* Untabification.Bill Wendling2009-05-301-1/+1
| | | | llvm-svn: 72604
* Have llvm_start_multithreaded return a bool indicating whether multithreadedOwen Anderson2009-05-201-2/+3
| | | | | | initialization succeeded or not, rather than just asserting. llvm-svn: 72182
* Add llvm_start_multithreaded(), which starts up the LLVM internals in ↵Owen Anderson2009-05-201-8/+45
| | | | | | | | thread-safe mode. Provide double-check locking initialization of ManagedStatic's when running in thread-safe mode. llvm-svn: 72151
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-291-2/+2
| | | | llvm-svn: 45418
* Not all managedstatics need object pointers.Chris Lattner2007-02-201-1/+1
| | | | llvm-svn: 34444
* Define this in the correct n/sChris Lattner2006-09-291-1/+1
| | | | llvm-svn: 30671
* new helper class to provide more explicit management of static ctor/dtors.Chris Lattner2006-09-281-0/+53
llvm-svn: 30638
OpenPOWER on IntegriCloud