@@ -629,7 +629,8 @@ class FunctionSummary : public GlobalValueSummary {
629
629
std::unique_ptr<TypeIdInfo> TIdInfo;
630
630
631
631
// / Uses for every parameter to this function.
632
- std::vector<ParamAccess> ParamAccesses;
632
+ using ParamAccessesTy = std::vector<ParamAccess>;
633
+ std::unique_ptr<ParamAccessesTy> ParamAccesses;
633
634
634
635
public:
635
636
FunctionSummary (GVFlags Flags, unsigned NumInsts, FFlags FunFlags,
@@ -640,19 +641,20 @@ class FunctionSummary : public GlobalValueSummary {
640
641
std::vector<VFuncId> TypeCheckedLoadVCalls,
641
642
std::vector<ConstVCall> TypeTestAssumeConstVCalls,
642
643
std::vector<ConstVCall> TypeCheckedLoadConstVCalls,
643
- std::vector<ParamAccess> ParamAccesses )
644
+ std::vector<ParamAccess> Params )
644
645
: GlobalValueSummary(FunctionKind, Flags, std::move(Refs)),
645
646
InstCount (NumInsts), FunFlags(FunFlags), EntryCount(EntryCount),
646
- CallGraphEdgeList(std::move(CGEdges)),
647
- ParamAccesses(std::move(ParamAccesses)) {
647
+ CallGraphEdgeList(std::move(CGEdges)) {
648
648
if (!TypeTests.empty () || !TypeTestAssumeVCalls.empty () ||
649
649
!TypeCheckedLoadVCalls.empty () || !TypeTestAssumeConstVCalls.empty () ||
650
650
!TypeCheckedLoadConstVCalls.empty ())
651
- TIdInfo = std::make_unique<TypeIdInfo>(TypeIdInfo{
652
- std::move (TypeTests), std::move (TypeTestAssumeVCalls),
653
- std::move (TypeCheckedLoadVCalls),
654
- std::move (TypeTestAssumeConstVCalls),
655
- std::move (TypeCheckedLoadConstVCalls)});
651
+ TIdInfo = std::make_unique<TypeIdInfo>(
652
+ TypeIdInfo{std::move (TypeTests), std::move (TypeTestAssumeVCalls),
653
+ std::move (TypeCheckedLoadVCalls),
654
+ std::move (TypeTestAssumeConstVCalls),
655
+ std::move (TypeCheckedLoadConstVCalls)});
656
+ if (!Params.empty ())
657
+ ParamAccesses = std::make_unique<ParamAccessesTy>(std::move (Params));
656
658
}
657
659
// Gets the number of readonly and writeonly refs in RefEdgeList
658
660
std::pair<unsigned , unsigned > specialRefCounts () const ;
@@ -724,11 +726,20 @@ class FunctionSummary : public GlobalValueSummary {
724
726
}
725
727
726
728
// / Returns the list of known uses of pointer parameters.
727
- ArrayRef<ParamAccess> paramAccesses () const { return ParamAccesses; }
729
+ ArrayRef<ParamAccess> paramAccesses () const {
730
+ if (ParamAccesses)
731
+ return *ParamAccesses;
732
+ return {};
733
+ }
728
734
729
735
// / Sets the list of known uses of pointer parameters.
730
736
void setParamAccesses (std::vector<ParamAccess> NewParams) {
731
- ParamAccesses = std::move (NewParams);
737
+ if (NewParams.empty ())
738
+ ParamAccesses.reset ();
739
+ else if (ParamAccesses)
740
+ *ParamAccesses = std::move (NewParams);
741
+ else
742
+ ParamAccesses = std::make_unique<ParamAccessesTy>(std::move (NewParams));
732
743
}
733
744
734
745
// / Add a type test to the summary. This is used by WholeProgramDevirt if we
0 commit comments