Skip to content

Commit 8fccf6b

Browse files
authored
[opt] Use static arrays instead of std::vector to store legacy pass names. NFC (llvm#83634)
A std::vector causes a heap allocation and a memcpy of static initialization data from the rodata section. Use a static array instead so we can use the static data directly.
1 parent 4dd9c2e commit 8fccf6b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/tools/opt/optdriver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ struct TimeTracerRAII {
317317
// TODO: use a codegen version of PassRegistry.def/PassBuilder::is*Pass() once
318318
// it exists.
319319
static bool shouldPinPassToLegacyPM(StringRef Pass) {
320-
std::vector<StringRef> PassNameExactToIgnore = {
320+
static constexpr StringLiteral PassNameExactToIgnore[] = {
321321
"nvvm-reflect",
322322
"nvvm-intr-range",
323323
"amdgpu-simplifylib",
@@ -334,13 +334,13 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
334334
if (llvm::is_contained(PassNameExactToIgnore, Pass))
335335
return false;
336336

337-
std::vector<StringRef> PassNamePrefix = {
337+
static constexpr StringLiteral PassNamePrefix[] = {
338338
"x86-", "xcore-", "wasm-", "systemz-", "ppc-", "nvvm-",
339339
"nvptx-", "mips-", "lanai-", "hexagon-", "bpf-", "avr-",
340340
"thumb2-", "arm-", "si-", "gcn-", "amdgpu-", "aarch64-",
341341
"amdgcn-", "polly-", "riscv-", "dxil-"};
342-
std::vector<StringRef> PassNameContain = {"-eh-prepare"};
343-
std::vector<StringRef> PassNameExact = {
342+
static constexpr StringLiteral PassNameContain[] = {"-eh-prepare"};
343+
static constexpr StringLiteral PassNameExact[] = {
344344
"safe-stack",
345345
"cost-model",
346346
"codegenprepare",

0 commit comments

Comments
 (0)