[opt] Use static arrays instead of std::vector to store legacy pass names. NFC (#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.
This commit is contained in:
Craig Topper 2024-03-02 17:47:40 -08:00 committed by GitHub
parent 4dd9c2ed32
commit 8fccf6bf5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -317,7 +317,7 @@ struct TimeTracerRAII {
// TODO: use a codegen version of PassRegistry.def/PassBuilder::is*Pass() once
// it exists.
static bool shouldPinPassToLegacyPM(StringRef Pass) {
std::vector<StringRef> PassNameExactToIgnore = {
static constexpr StringLiteral PassNameExactToIgnore[] = {
"nvvm-reflect",
"nvvm-intr-range",
"amdgpu-simplifylib",
@ -334,13 +334,13 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
if (llvm::is_contained(PassNameExactToIgnore, Pass))
return false;
std::vector<StringRef> PassNamePrefix = {
static constexpr StringLiteral PassNamePrefix[] = {
"x86-", "xcore-", "wasm-", "systemz-", "ppc-", "nvvm-",
"nvptx-", "mips-", "lanai-", "hexagon-", "bpf-", "avr-",
"thumb2-", "arm-", "si-", "gcn-", "amdgpu-", "aarch64-",
"amdgcn-", "polly-", "riscv-", "dxil-"};
std::vector<StringRef> PassNameContain = {"-eh-prepare"};
std::vector<StringRef> PassNameExact = {
static constexpr StringLiteral PassNameContain[] = {"-eh-prepare"};
static constexpr StringLiteral PassNameExact[] = {
"safe-stack",
"cost-model",
"codegenprepare",