[llvm] change GlobalValueSummaryMapTy from std::map to llvm::MapVector (PR #157839)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 10 04:55:42 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/include/llvm/IR/ModuleSummaryIndex.h llvm/include/llvm/IR/ModuleSummaryIndexYAML.h llvm/lib/AsmParser/LLParser.cpp
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index d7f8cc105..e476a9eed 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -184,18 +184,18 @@ using GlobalValueSummaryMapTy =
/// summary.
struct ValueInfo {
enum Flags { HaveGV = 1, ReadOnly = 2, WriteOnly = 4 };
- PointerIntPair<const GlobalValueSummaryMapTy *, 3, int>
- RefAndFlags;
- PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 1, bool>
- Offset;
+ PointerIntPair<const GlobalValueSummaryMapTy *, 3, int> RefAndFlags;
+ PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 1, bool> Offset;
ValueInfo() = default;
- ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R, const GlobalValueSummaryMapTy *Map/* = nullptr*/) {
+ ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R,
+ const GlobalValueSummaryMapTy *Map /* = nullptr*/) {
RefAndFlags.setPointer(Map);
RefAndFlags.setInt(HaveGVs);
Offset.setPointer(R);
if (R != nullptr && Map != nullptr)
- Offset.setPointer((const GlobalValueSummaryMapTy::value_type *)((uintptr_t)R - (uintptr_t)Map->begin()));
+ Offset.setPointer((const GlobalValueSummaryMapTy::value_type
+ *)((uintptr_t)R - (uintptr_t)Map->begin()));
if (R != nullptr)
Offset.setInt(true);
}
@@ -252,7 +252,9 @@ struct ValueInfo {
const GlobalValueSummaryMapTy::value_type *getRef() const {
if (RefAndFlags.getPointer())
- return RefAndFlags.getPointer()->begin() + (intptr_t)Offset.getPointer() / sizeof(GlobalValueSummaryMapTy::value_type);
+ return RefAndFlags.getPointer()->begin() +
+ (intptr_t)Offset.getPointer() /
+ sizeof(GlobalValueSummaryMapTy::value_type);
return Offset.getPointer();
}
@@ -300,7 +302,8 @@ template <> struct DenseMapInfo<ValueInfo> {
}
static inline ValueInfo getTombstoneKey() {
- return ValueInfo(false, (GlobalValueSummaryMapTy::value_type *)-16, nullptr);
+ return ValueInfo(false, (GlobalValueSummaryMapTy::value_type *)-16,
+ nullptr);
}
static inline bool isSpecialKey(ValueInfo V) {
@@ -311,7 +314,8 @@ template <> struct DenseMapInfo<ValueInfo> {
// We are not supposed to mix ValueInfo(s) with different HaveGVs flag
// in a same container.
assert(isSpecialKey(L) || isSpecialKey(R) || (L.haveGVs() == R.haveGVs()));
- return L.Offset == R.Offset && L.RefAndFlags.getPointer() == R.RefAndFlags.getPointer();
+ return L.Offset == R.Offset &&
+ L.RefAndFlags.getPointer() == R.RefAndFlags.getPointer();
}
static unsigned getHashValue(ValueInfo I) { return hash_value(I.getRef()); }
};
@@ -1407,7 +1411,8 @@ class ModuleSummaryIndex {
private:
/// Map from value name to list of summary instances for values of that
/// name (may be duplicates in the COMDAT case, e.g.).
- std::unique_ptr<GlobalValueSummaryMapTy> GlobalValueMap = std::make_unique<GlobalValueSummaryMapTy>();
+ std::unique_ptr<GlobalValueSummaryMapTy> GlobalValueMap =
+ std::make_unique<GlobalValueSummaryMapTy>();
/// Holds strings for combined index, mapping to the corresponding module ID.
ModulePathStringTableTy ModulePathStringTable;
@@ -1620,7 +1625,8 @@ public:
if (!S.second.SummaryList.size() ||
!isa<FunctionSummary>(S.second.SummaryList.front().get()))
continue;
- discoverNodes(ValueInfo(HaveGVs, &S, GlobalValueMap.get()), FunctionHasParent);
+ discoverNodes(ValueInfo(HaveGVs, &S, GlobalValueMap.get()),
+ FunctionHasParent);
}
SmallVector<FunctionSummary::EdgeTy, 0> Edges;
@@ -1693,7 +1699,8 @@ public:
/// Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
ValueInfo getValueInfo(GlobalValue::GUID GUID) const {
auto I = GlobalValueMap->find(GUID);
- return ValueInfo(HaveGVs, I == GlobalValueMap->end() ? nullptr : &*I, GlobalValueMap.get());
+ return ValueInfo(HaveGVs, I == GlobalValueMap->end() ? nullptr : &*I,
+ GlobalValueMap.get());
}
/// Return a ValueInfo for \p GUID.
``````````
</details>
https://github.com/llvm/llvm-project/pull/157839
More information about the llvm-commits
mailing list