Skip to content

Commit fd75496

Browse files
bors[bot]vext01
andauthored
66: Make yk build with `-Werror,-Wglobal-constructors`. r=jacob-hughes a=vext01 Co-authored-by: Edd Barrett <vext01@gmail.com>
2 parents 4e274e6 + 9caf1de commit fd75496

File tree

3 files changed

+101
-26
lines changed

3 files changed

+101
-26
lines changed

llvm/include/llvm/Support/Yk.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __LLVM_SUPPORT_YK_H
2+
#define __LLVM_SUPPORT_YK_H
3+
4+
namespace llvm {
5+
void initYkOptions(void);
6+
} // namespace llvm
7+
8+
#endif

llvm/lib/Support/CommandLine.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "llvm/Support/Process.h"
4141
#include "llvm/Support/StringSaver.h"
4242
#include "llvm/Support/VirtualFileSystem.h"
43+
#include "llvm/Support/Yk.h"
4344
#include "llvm/Support/raw_ostream.h"
4445
#include <cstdlib>
4546
#include <optional>
@@ -2672,6 +2673,7 @@ static void initCommonOptions() {
26722673
initWithColorOptions();
26732674
initDebugOptions();
26742675
initRandomSeedOptions();
2676+
initYkOptions();
26752677
}
26762678

26772679
OptionCategory &cl::getGeneralCategory() {

llvm/lib/Support/Yk.cpp

+91-26
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,106 @@
1+
#include "llvm/Support/Yk.h"
12
#include "llvm/Support/CommandLine.h"
3+
#include "llvm/Support/ManagedStatic.h"
24

35
using namespace llvm;
46

57
bool YkAllocLLVMBCSection;
6-
static cl::opt<bool, true> YkAllocLLVMBCSectionParser(
7-
"yk-alloc-llvmbc-section", cl::desc("Make the `.llvmbc` section loadable"),
8-
cl::NotHidden, cl::location(YkAllocLLVMBCSection));
8+
namespace {
9+
struct CreateYkAllocLLVMBCSectionParser {
10+
static void *call() {
11+
return new cl::opt<bool, true>(
12+
"yk-alloc-llvmbc-section",
13+
cl::desc("Make the `.llvmbc` section loadable"), cl::NotHidden,
14+
cl::location(YkAllocLLVMBCSection));
15+
}
16+
};
17+
} // namespace
18+
static ManagedStatic<cl::opt<bool, true>, CreateYkAllocLLVMBCSectionParser>
19+
YkAllocLLVMBCSectionParser;
920

1021
bool YkAllocLLVMBBAddrMapSection;
11-
static cl::opt<bool, true> YkAllocLLVMBBAddrMapSectionParser(
12-
"yk-alloc-llvmbbaddrmap-section",
13-
cl::desc("Make the `.llvmbbaddrmap` section loadable"), cl::NotHidden,
14-
cl::location(YkAllocLLVMBBAddrMapSection));
22+
namespace {
23+
struct CreateYkAllocLLVMBBAddrMapSectionParser {
24+
static void *call() {
25+
return new cl::opt<bool, true>(
26+
"yk-alloc-llvmbbaddrmap-section",
27+
cl::desc("Make the `.llvmbbaddrmap` section loadable"), cl::NotHidden,
28+
cl::location(YkAllocLLVMBBAddrMapSection));
29+
}
30+
};
31+
} // namespace
32+
static ManagedStatic<cl::opt<bool, true>,
33+
CreateYkAllocLLVMBBAddrMapSectionParser>
34+
YkAllocLLVMBBAddrMapSectionParser;
1535

1636
bool YkExtendedLLVMBBAddrMapSection;
17-
static cl::opt<bool, true> YkExtendedLLVMBBAddrMapSectionParser(
18-
"yk-extended-llvmbbaddrmap-section",
19-
cl::desc("Use the extended Yk `.llvmbbaddrmap` section format"),
20-
cl::NotHidden, cl::location(YkExtendedLLVMBBAddrMapSection));
37+
namespace {
38+
struct CreateYkExtendedLLVMBBAddrMapSectionParser {
39+
static void *call() {
40+
return new cl::opt<bool, true>(
41+
"yk-extended-llvmbbaddrmap-section",
42+
cl::desc("Use the extended Yk `.llvmbbaddrmap` section format"),
43+
cl::NotHidden, cl::location(YkExtendedLLVMBBAddrMapSection));
44+
}
45+
};
46+
} // namespace
47+
static ManagedStatic<cl::opt<bool, true>,
48+
CreateYkExtendedLLVMBBAddrMapSectionParser>
49+
YkExtendedLLVMBBAddrMapSectionParser;
2150

2251
bool YkStackMapOffsetFix;
23-
static cl::opt<bool, true> YkStackMapOffsetFixParser(
24-
"yk-stackmap-offset-fix",
25-
cl::desc("Apply a fix to stackmaps that corrects the reported instruction "
26-
"offset in the presence of calls. (deprecated by "
27-
"yk-stackmap-spillreloads-fix)"),
28-
cl::NotHidden, cl::location(YkStackMapOffsetFix));
52+
namespace {
53+
struct CreateYkStackMapOffsetFixParser {
54+
static void *call() {
55+
return new cl::opt<bool, true>(
56+
"yk-stackmap-offset-fix",
57+
cl::desc(
58+
"Apply a fix to stackmaps that corrects the reported instruction "
59+
"offset in the presence of calls. (deprecated by "
60+
"yk-stackmap-spillreloads-fix)"),
61+
cl::NotHidden, cl::location(YkStackMapOffsetFix));
62+
}
63+
};
64+
} // namespace
65+
static ManagedStatic<cl::opt<bool, true>, CreateYkStackMapOffsetFixParser>
66+
YkStackMapOffsetFixParser;
2967

3068
bool YkStackMapAdditionalLocs;
31-
static cl::opt<bool, true> YkStackMapAdditionalLocsParser(
32-
"yk-stackmap-add-locs",
33-
cl::desc("Encode additional locations for registers into stackmaps."),
34-
cl::NotHidden, cl::location(YkStackMapAdditionalLocs));
69+
namespace {
70+
struct CreateYkStackMapAdditionalLocsParser {
71+
static void *call() {
72+
return new cl::opt<bool, true>(
73+
"yk-stackmap-add-locs",
74+
cl::desc("Encode additional locations for registers into stackmaps."),
75+
cl::NotHidden, cl::location(YkStackMapAdditionalLocs));
76+
}
77+
};
78+
} // namespace
79+
static ManagedStatic<cl::opt<bool, true>, CreateYkStackMapAdditionalLocsParser>
80+
YkStackMapAdditionalLocsParser;
3581

3682
bool YkStackmapsSpillReloadsFix;
37-
static cl::opt<bool, true> YkStackMapSpillFixParser(
38-
"yk-stackmap-spillreloads-fix",
39-
cl::desc("Revert stackmaps and its operands after the register allocator "
40-
"has emitted spill reloads."),
41-
cl::NotHidden, cl::location(YkStackmapsSpillReloadsFix));
83+
namespace {
84+
struct CreateYkStackmapsSpillReloadsFixParser {
85+
static void *call() {
86+
return new cl::opt<bool, true>(
87+
"yk-stackmap-spillreloads-fix",
88+
cl::desc(
89+
"Revert stackmaps and its operands after the register allocator "
90+
"has emitted spill reloads."),
91+
cl::NotHidden, cl::location(YkStackmapsSpillReloadsFix));
92+
}
93+
};
94+
} // namespace
95+
static ManagedStatic<cl::opt<bool, true>,
96+
CreateYkStackmapsSpillReloadsFixParser>
97+
YkStackmapsSpillFixParser;
98+
99+
void llvm::initYkOptions() {
100+
*YkAllocLLVMBCSectionParser;
101+
*YkAllocLLVMBBAddrMapSectionParser;
102+
*YkExtendedLLVMBBAddrMapSectionParser;
103+
*YkStackMapOffsetFixParser;
104+
*YkStackMapAdditionalLocsParser;
105+
*YkStackmapsSpillFixParser;
106+
}

0 commit comments

Comments
 (0)