[PATCH] D128726: [RISCV][NFC] Move static global variables into static variable in function.
Kito Cheng via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 28 06:15:15 PDT 2022
kito-cheng created this revision.
Herald added subscribers: sunshaoce, VincentWu, luke957, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson.
Herald added a project: All.
kito-cheng requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.
It's violate coding guideline in LLVM coding standard[1], and the
variable seems only used to cache the query result, so this could be
just a static variable within function.
[1] https://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128726
Files:
clang/lib/Support/RISCVVIntrinsicUtils.cpp
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===================================================================
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -31,10 +31,6 @@
const PrototypeDescriptor PrototypeDescriptor::Vector =
PrototypeDescriptor(BaseTypeModifier::Vector);
-// Concat BasicType, LMUL and Proto as key
-static std::unordered_map<uint64_t, RVVType> LegalTypes;
-static std::set<uint64_t> IllegalTypes;
-
//===----------------------------------------------------------------------===//
// Type implementation
//===----------------------------------------------------------------------===//
@@ -822,6 +818,9 @@
Optional<RVVTypePtr> RVVType::computeType(BasicType BT, int Log2LMUL,
PrototypeDescriptor Proto) {
+ // Concat BasicType, LMUL and Proto as key
+ static std::unordered_map<uint64_t, RVVType> LegalTypes;
+ static std::set<uint64_t> IllegalTypes;
uint64_t Idx = computeRVVTypeHashValue(BT, Log2LMUL, Proto);
// Search first
auto It = LegalTypes.find(Idx);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128726.440585.patch
Type: text/x-patch
Size: 1107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220628/6473a8ba/attachment.bin>
More information about the cfe-commits
mailing list