[llvm] 8fccf6b - [opt] Use static arrays instead of std::vector to store legacy pass names. NFC (#83634)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 2 17:47:43 PST 2024
Author: Craig Topper
Date: 2024-03-02T17:47:40-08:00
New Revision: 8fccf6bf5ccb4404cfe184ceda7c32e349e122c0
URL: https://github.com/llvm/llvm-project/commit/8fccf6bf5ccb4404cfe184ceda7c32e349e122c0
DIFF: https://github.com/llvm/llvm-project/commit/8fccf6bf5ccb4404cfe184ceda7c32e349e122c0.diff
LOG: [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.
Added:
Modified:
llvm/tools/opt/optdriver.cpp
Removed:
################################################################################
diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp
index 7d05cb412b3d5a..948148bb80498c 100644
--- a/llvm/tools/opt/optdriver.cpp
+++ b/llvm/tools/opt/optdriver.cpp
@@ -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",
More information about the llvm-commits
mailing list