[llvm-commits] [llvm] r74230 - /llvm/trunk/lib/CompilerDriver/Plugin.cpp
Owen Anderson
resistor at mac.com
Thu Jun 25 17:06:28 PDT 2009
Author: resistor
Date: Thu Jun 25 19:06:28 2009
New Revision: 74230
URL: http://llvm.org/viewvc/llvm-project?rev=74230&view=rev
Log:
Guards for the compiler driver plugin list.
Modified:
llvm/trunk/lib/CompilerDriver/Plugin.cpp
Modified: llvm/trunk/lib/CompilerDriver/Plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Plugin.cpp?rev=74230&r1=74229&r2=74230&view=diff
==============================================================================
--- llvm/trunk/lib/CompilerDriver/Plugin.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/Plugin.cpp Thu Jun 25 19:06:28 2009
@@ -12,7 +12,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/CompilerDriver/Plugin.h"
-
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/System/Mutex.h"
#include <algorithm>
#include <vector>
@@ -28,6 +29,7 @@
static bool pluginListInitialized = false;
typedef std::vector<const llvmc::BasePlugin*> PluginList;
static PluginList Plugins;
+ static llvm::ManagedStatic<llvm::sys::SmartMutex<true> > PluginMutex;
struct ByPriority {
bool operator()(const llvmc::BasePlugin* lhs,
@@ -40,6 +42,7 @@
namespace llvmc {
PluginLoader::PluginLoader() {
+ llvm::sys::SmartScopedLock<true> Lock(&*PluginMutex);
if (!pluginListInitialized) {
for (PluginRegistry::iterator B = PluginRegistry::begin(),
E = PluginRegistry::end(); B != E; ++B)
@@ -50,6 +53,7 @@
}
PluginLoader::~PluginLoader() {
+ llvm::sys::SmartScopedLock<true> Lock(&*PluginMutex);
if (pluginListInitialized) {
for (PluginList::iterator B = Plugins.begin(), E = Plugins.end();
B != E; ++B)
@@ -59,12 +63,14 @@
}
void PluginLoader::PopulateLanguageMap(LanguageMap& langMap) {
+ llvm::sys::SmartScopedLock<true> Lock(&*PluginMutex);
for (PluginList::iterator B = Plugins.begin(), E = Plugins.end();
B != E; ++B)
(*B)->PopulateLanguageMap(langMap);
}
void PluginLoader::PopulateCompilationGraph(CompilationGraph& graph) {
+ llvm::sys::SmartScopedLock<true> Lock(&*PluginMutex);
for (PluginList::iterator B = Plugins.begin(), E = Plugins.end();
B != E; ++B)
(*B)->PopulateCompilationGraph(graph);
More information about the llvm-commits
mailing list