Skip to content

Commit 6ac5cbd

Browse files
authored
[NFC][LLVM] Eliminate duplicate code in INITIALIZE_PASS macros (#134457)
- Refactor INITIALIZE_PASS and INITIALIZE_PASS_WITH_OPTIONS macros to eliminate some code duplication.
1 parent c07ab9e commit 6ac5cbd

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

llvm/include/llvm/PassSupport.h

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,6 @@ namespace llvm {
3535

3636
class Pass;
3737

38-
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
39-
static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
40-
PassInfo *PI = new PassInfo( \
41-
name, arg, &passName::ID, \
42-
PassInfo::NormalCtor_t(callDefaultCtor<passName>), cfg, analysis); \
43-
Registry.registerPass(*PI, true); \
44-
return PI; \
45-
} \
46-
static llvm::once_flag Initialize##passName##PassFlag; \
47-
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
48-
llvm::call_once(Initialize##passName##PassFlag, \
49-
initialize##passName##PassOnce, std::ref(Registry)); \
50-
}
51-
5238
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
5339
static void *initialize##passName##PassOnce(PassRegistry &Registry) {
5440

@@ -67,15 +53,18 @@ class Pass;
6753
initialize##passName##PassOnce, std::ref(Registry)); \
6854
}
6955

70-
#define INITIALIZE_PASS_WITH_OPTIONS(PassName, Arg, Name, Cfg, Analysis) \
71-
INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
72-
PassName::registerOptions(); \
73-
INITIALIZE_PASS_END(PassName, Arg, Name, Cfg, Analysis)
56+
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
57+
INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
58+
INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
7459

7560
#define INITIALIZE_PASS_WITH_OPTIONS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
7661
INITIALIZE_PASS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
7762
PassName::registerOptions();
7863

64+
#define INITIALIZE_PASS_WITH_OPTIONS(PassName, Arg, Name, Cfg, Analysis) \
65+
INITIALIZE_PASS_WITH_OPTIONS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
66+
INITIALIZE_PASS_END(PassName, Arg, Name, Cfg, Analysis)
67+
7968
template <
8069
class PassName,
8170
std::enable_if_t<std::is_default_constructible<PassName>{}, bool> = true>

0 commit comments

Comments
 (0)