[llvm] r271657 - Revert "[LPM] Replace the CALL_ONCE_... macro in the legacy pass manager with the new llvm::call_once facility."
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 03:36:11 PDT 2016
Author: d0k
Date: Fri Jun 3 05:36:10 2016
New Revision: 271657
URL: http://llvm.org/viewvc/llvm-project?rev=271657&view=rev
Log:
Revert "[LPM] Replace the CALL_ONCE_... macro in the legacy pass manager with the new llvm::call_once facility."
Fallback path doesn't compile. This reverts commit r271652.
Modified:
llvm/trunk/include/llvm/CodeGen/Passes.h
llvm/trunk/include/llvm/PassSupport.h
Modified: llvm/trunk/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=271657&r1=271656&r2=271657&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/Passes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Jun 3 05:36:10 2016
@@ -377,10 +377,8 @@ namespace llvm {
Registry.registerPass(*PI, true); \
return PI; \
} \
- LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
- std::ref(Registry)); \
+ CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
}
/// This initializer registers TargetMachine constructor, so the pass being
Modified: llvm/trunk/include/llvm/PassSupport.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=271657&r1=271656&r2=271657&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassSupport.h (original)
+++ llvm/trunk/include/llvm/PassSupport.h Fri Jun 3 05:36:10 2016
@@ -26,13 +26,31 @@
#include "llvm/PassInfo.h"
#include "llvm/PassRegistry.h"
#include "llvm/Support/Atomic.h"
-#include "llvm/Support/Threading.h"
-#include <functional>
namespace llvm {
class TargetMachine;
+#define CALL_ONCE_INITIALIZATION(function) \
+ static volatile sys::cas_flag initialized = 0; \
+ sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
+ if (old_val == 0) { \
+ function(Registry); \
+ sys::MemoryFence(); \
+ TsanIgnoreWritesBegin(); \
+ TsanHappensBefore(&initialized); \
+ initialized = 2; \
+ TsanIgnoreWritesEnd(); \
+ } else { \
+ sys::cas_flag tmp = initialized; \
+ sys::MemoryFence(); \
+ while (tmp != 2) { \
+ tmp = initialized; \
+ sys::MemoryFence(); \
+ } \
+ } \
+ TsanHappensAfter(&initialized);
+
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
PassInfo *PI = new PassInfo( \
@@ -41,10 +59,8 @@ class TargetMachine;
Registry.registerPass(*PI, true); \
return PI; \
} \
- LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
- std::ref(Registry)); \
+ CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
}
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
@@ -61,10 +77,8 @@ class TargetMachine;
Registry.registerPass(*PI, true); \
return PI; \
} \
- LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
- std::ref(Registry)); \
+ CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
}
#define INITIALIZE_PASS_WITH_OPTIONS(PassName, Arg, Name, Cfg, Analysis) \
@@ -152,10 +166,8 @@ struct RegisterAnalysisGroup : public Re
Registry.registerAnalysisGroup(&agName::ID, 0, *AI, false, true); \
return AI; \
} \
- LLVM_DEFINE_ONCE_FLAG(Initialize##agName##AnalysisGroupFlag); \
void llvm::initialize##agName##AnalysisGroup(PassRegistry &Registry) { \
- call_once(Initialize##agName##AnalysisGroupFlag, \
- initialize##agName##AnalysisGroupOnce, std::ref(Registry)); \
+ CALL_ONCE_INITIALIZATION(initialize##agName##AnalysisGroupOnce) \
}
#define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
@@ -172,10 +184,8 @@ struct RegisterAnalysisGroup : public Re
true); \
return AI; \
} \
- LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
- std::ref(Registry)); \
+ CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
}
#define INITIALIZE_AG_PASS_BEGIN(passName, agName, arg, n, cfg, analysis, def) \
@@ -193,10 +203,8 @@ struct RegisterAnalysisGroup : public Re
Registry.registerAnalysisGroup(&agName::ID, &passName::ID, *AI, def, true); \
return AI; \
} \
- LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
- std::ref(Registry)); \
+ CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
}
//===---------------------------------------------------------------------------
More information about the llvm-commits
mailing list