[llvm] 57f2a78 - [StackSafety,NFC] Reduce FunctionSummary size
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 18:01:53 PDT 2020
Author: Vitaly Buka
Date: 2020-07-09T18:01:39-07:00
New Revision: 57f2a789ca074165baa1c8eea3332007477c9f91
URL: https://github.com/llvm/llvm-project/commit/57f2a789ca074165baa1c8eea3332007477c9f91
DIFF: https://github.com/llvm/llvm-project/commit/57f2a789ca074165baa1c8eea3332007477c9f91.diff
LOG: [StackSafety,NFC] Reduce FunctionSummary size
Most compiler infocations will not need ParamAccess,
so we can optimize memory usage there with smaller unique_ptr
instead of empty vector.
Suggested in D80908 review.
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D83458
Added:
Modified:
llvm/include/llvm/IR/ModuleSummaryIndex.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 9adaf5dfc3d3..4cfd4e916200 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -629,7 +629,8 @@ class FunctionSummary : public GlobalValueSummary {
std::unique_ptr<TypeIdInfo> TIdInfo;
/// Uses for every parameter to this function.
- std::vector<ParamAccess> ParamAccesses;
+ using ParamAccessesTy = std::vector<ParamAccess>;
+ std::unique_ptr<ParamAccessesTy> ParamAccesses;
public:
FunctionSummary(GVFlags Flags, unsigned NumInsts, FFlags FunFlags,
@@ -640,19 +641,20 @@ class FunctionSummary : public GlobalValueSummary {
std::vector<VFuncId> TypeCheckedLoadVCalls,
std::vector<ConstVCall> TypeTestAssumeConstVCalls,
std::vector<ConstVCall> TypeCheckedLoadConstVCalls,
- std::vector<ParamAccess> ParamAccesses)
+ std::vector<ParamAccess> Params)
: GlobalValueSummary(FunctionKind, Flags, std::move(Refs)),
InstCount(NumInsts), FunFlags(FunFlags), EntryCount(EntryCount),
- CallGraphEdgeList(std::move(CGEdges)),
- ParamAccesses(std::move(ParamAccesses)) {
+ CallGraphEdgeList(std::move(CGEdges)) {
if (!TypeTests.empty() || !TypeTestAssumeVCalls.empty() ||
!TypeCheckedLoadVCalls.empty() || !TypeTestAssumeConstVCalls.empty() ||
!TypeCheckedLoadConstVCalls.empty())
- TIdInfo = std::make_unique<TypeIdInfo>(TypeIdInfo{
- std::move(TypeTests), std::move(TypeTestAssumeVCalls),
- std::move(TypeCheckedLoadVCalls),
- std::move(TypeTestAssumeConstVCalls),
- std::move(TypeCheckedLoadConstVCalls)});
+ TIdInfo = std::make_unique<TypeIdInfo>(
+ TypeIdInfo{std::move(TypeTests), std::move(TypeTestAssumeVCalls),
+ std::move(TypeCheckedLoadVCalls),
+ std::move(TypeTestAssumeConstVCalls),
+ std::move(TypeCheckedLoadConstVCalls)});
+ if (!Params.empty())
+ ParamAccesses = std::make_unique<ParamAccessesTy>(std::move(Params));
}
// Gets the number of readonly and writeonly refs in RefEdgeList
std::pair<unsigned, unsigned> specialRefCounts() const;
@@ -724,11 +726,20 @@ class FunctionSummary : public GlobalValueSummary {
}
/// Returns the list of known uses of pointer parameters.
- ArrayRef<ParamAccess> paramAccesses() const { return ParamAccesses; }
+ ArrayRef<ParamAccess> paramAccesses() const {
+ if (ParamAccesses)
+ return *ParamAccesses;
+ return {};
+ }
/// Sets the list of known uses of pointer parameters.
void setParamAccesses(std::vector<ParamAccess> NewParams) {
- ParamAccesses = std::move(NewParams);
+ if (NewParams.empty())
+ ParamAccesses.reset();
+ else if (ParamAccesses)
+ *ParamAccesses = std::move(NewParams);
+ else
+ ParamAccesses = std::make_unique<ParamAccessesTy>(std::move(NewParams));
}
/// Add a type test to the summary. This is used by WholeProgramDevirt if we
More information about the llvm-commits
mailing list