Skip to content

Commit fcad028

Browse files
committed
[region-isolation] Move the region isolation logging decls out of PartitionUtils.h -> RegionIsolation.h
These do not specifically have to do with PartitionUtils... they are really logging options for the whole infrastructure, so it makes sense to have them in the a different file. (cherry picked from commit b477433)
1 parent 53e61d3 commit fcad028

File tree

5 files changed

+99
-54
lines changed

5 files changed

+99
-54
lines changed

include/swift/SILOptimizer/Utils/PartitionUtils.h

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/SIL/SILFunction.h"
2121
#include "swift/SIL/SILInstruction.h"
2222
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
23+
#include "swift/SILOptimizer/Utils/RegionIsolation.h"
2324
#include "swift/SILOptimizer/Utils/SILIsolationInfo.h"
2425

2526
#include "llvm/ADT/MapVector.h"
@@ -36,32 +37,6 @@ namespace swift {
3637

3738
namespace PartitionPrimitives {
3839

39-
extern bool REGIONBASEDISOLATION_ENABLE_LOGGING;
40-
41-
#ifdef REGIONBASEDISOLATION_LOG
42-
#error "REGIONBASEDISOLATION_LOG already defined?!"
43-
#endif
44-
45-
#define REGIONBASEDISOLATION_LOG(...) \
46-
do { \
47-
if (PartitionPrimitives::REGIONBASEDISOLATION_ENABLE_LOGGING) { \
48-
__VA_ARGS__; \
49-
} \
50-
} while (0);
51-
52-
extern bool REGIONBASEDISOLATION_ENABLE_VERBOSE_LOGGING;
53-
54-
#ifdef REGIONBASEDISOLATION_VERBOSE_LOG
55-
#error "REGIONBASEDISOLATION_VERBOSE_LOG already defined?!"
56-
#endif
57-
58-
#define REGIONBASEDISOLATION_VERBOSE_LOG(...) \
59-
do { \
60-
if (PartitionPrimitives::REGIONBASEDISOLATION_ENABLE_VERBOSE_LOGGING) { \
61-
__VA_ARGS__; \
62-
} \
63-
} while (0);
64-
6540
struct Element {
6641
unsigned num;
6742

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//===--- RegionIsolation.h ------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
///
13+
/// \file This file just declares some command line options that are used for
14+
/// the various parts of region analysis based diagnostics.
15+
///
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef SWIFT_SILOPTIMIZER_UTILS_REGIONANALYSIS_H
19+
#define SWIFT_SILOPTIMIZER_UTILS_REGIONANALYSIS_H
20+
21+
namespace swift {
22+
23+
namespace regionisolation {
24+
25+
enum class LoggingFlag {
26+
Off = 0,
27+
Normal = 0x1,
28+
Verbose = 0x3,
29+
};
30+
31+
extern LoggingFlag ENABLE_LOGGING;
32+
33+
#ifdef REGIONBASEDISOLATION_LOG
34+
#error "REGIONBASEDISOLATION_LOG already defined?!"
35+
#endif
36+
37+
#ifdef REGIONBASEDISOLATION_VERBOSE_LOG
38+
#error "REGIONBASEDISOLATION_VERBOSE_LOG already defined?!"
39+
#endif
40+
41+
#define REGIONBASEDISOLATION_LOG(...) \
42+
do { \
43+
if (swift::regionisolation::ENABLE_LOGGING != \
44+
swift::regionisolation::LoggingFlag::Off) { \
45+
__VA_ARGS__; \
46+
} \
47+
} while (0);
48+
49+
#define REGIONBASEDISOLATION_VERBOSE_LOG(...) \
50+
do { \
51+
if (swift::regionisolation::ENABLE_LOGGING == \
52+
swift::regionisolation::LoggingFlag::Verbose) { \
53+
__VA_ARGS__; \
54+
} \
55+
} while (0);
56+
57+
} // namespace regionisolation
58+
59+
} // namespace swift
60+
61+
#endif

lib/SILOptimizer/Utils/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ target_sources(swiftSILOptimizer PRIVATE
2222
LexicalDestroyHoisting.cpp
2323
LoopUtils.cpp
2424
OptimizerStatsUtils.cpp
25+
RegionIsolation.cpp
2526
PartialApplyCombiner.cpp
2627
PartitionUtils.cpp
2728
PerformanceInlinerUtils.cpp

lib/SILOptimizer/Utils/PartitionUtils.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,10 @@
2020
#include "swift/SIL/SILGlobalVariable.h"
2121
#include "swift/SILOptimizer/Utils/VariableNameUtils.h"
2222

23-
#include "llvm/Support/CommandLine.h"
24-
2523
using namespace swift;
2624
using namespace swift::PatternMatch;
2725
using namespace swift::PartitionPrimitives;
2826

29-
//===----------------------------------------------------------------------===//
30-
// MARK: Logging
31-
//===----------------------------------------------------------------------===//
32-
33-
bool swift::PartitionPrimitives::REGIONBASEDISOLATION_ENABLE_LOGGING;
34-
35-
static llvm::cl::opt<bool, true> // The parser
36-
RegionBasedIsolationLog(
37-
"sil-regionbasedisolation-log",
38-
llvm::cl::desc("Enable logging for SIL region based isolation "
39-
"diagnostics"),
40-
llvm::cl::Hidden,
41-
llvm::cl::location(
42-
swift::PartitionPrimitives::REGIONBASEDISOLATION_ENABLE_LOGGING));
43-
44-
bool swift::PartitionPrimitives::REGIONBASEDISOLATION_ENABLE_VERBOSE_LOGGING;
45-
46-
static llvm::cl::opt<bool, true> // The parser
47-
RegionBasedIsolationVerboseLog(
48-
"sil-regionbasedisolation-verbose-log",
49-
llvm::cl::desc("Enable verbose logging for SIL region based isolation "
50-
"diagnostics"),
51-
llvm::cl::Hidden,
52-
llvm::cl::location(swift::PartitionPrimitives::
53-
REGIONBASEDISOLATION_ENABLE_VERBOSE_LOGGING));
54-
5527
//===----------------------------------------------------------------------===//
5628
// MARK: PartitionOp
5729
//===----------------------------------------------------------------------===//
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===--- RegionIsolation.cpp ----------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "swift/SILOptimizer/Utils/RegionIsolation.h"
14+
15+
#include "llvm/Support/CommandLine.h"
16+
17+
using namespace swift;
18+
using namespace regionisolation;
19+
20+
//===----------------------------------------------------------------------===//
21+
// MARK: Logging
22+
//===----------------------------------------------------------------------===//
23+
24+
LoggingFlag swift::regionisolation::ENABLE_LOGGING;
25+
26+
static llvm::cl::opt<LoggingFlag, true> // The parser
27+
RegionBasedIsolationLog(
28+
"sil-regionbasedisolation-log",
29+
llvm::cl::desc("Enable logging for SIL region based isolation "
30+
"diagnostics"),
31+
llvm::cl::Hidden,
32+
llvm::cl::values(
33+
clEnumValN(LoggingFlag::Off, "none", "no logging"),
34+
clEnumValN(LoggingFlag::Normal, "on", "non verbose logging"),
35+
clEnumValN(LoggingFlag::Verbose, "verbose", "verbose logging")),
36+
llvm::cl::location(swift::regionisolation::ENABLE_LOGGING));

0 commit comments

Comments
 (0)