@@ -69,27 +69,9 @@ class GlobalValueSummary;
69
69
using GlobalValueSummaryList = std::vector<std::unique_ptr<GlobalValueSummary>>;
70
70
71
71
struct GlobalValueSummaryInfo {
72
- union NameOrGV {
73
- NameOrGV (bool IsAnalysis) {
74
- if (IsAnalysis)
75
- GV = nullptr ;
76
- else
77
- Name = " " ;
78
- }
79
-
80
- // / The GlobalValue corresponding to this summary. This is only used in
81
- // / per-module summaries, when module analysis is being run.
82
- const GlobalValue *GV;
83
-
84
- // / Summary string representation. This StringRef points to BC module
85
- // / string table and is valid until module data is stored in memory.
86
- // / This is guaranteed to happen until runThinLTOBackend function is
87
- // / called, so it is safe to use this field during thin link. This field
88
- // / is only valid if summary index was loaded from BC file.
89
- StringRef Name;
90
- } U;
91
-
92
- GlobalValueSummaryInfo (bool IsAnalysis) : U(IsAnalysis) {}
72
+ // / The GlobalValue corresponding to this summary. This is only used in
73
+ // / per-module summaries.
74
+ const GlobalValue *GV = nullptr ;
93
75
94
76
// / List of global value summary structures for a particular value held
95
77
// / in the GlobalValueMap. Requires a vector in the case of multiple
@@ -109,60 +91,32 @@ using GlobalValueSummaryMapTy =
109
91
// / Struct that holds a reference to a particular GUID in a global value
110
92
// / summary.
111
93
struct ValueInfo {
112
- PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 1 , bool >
113
- RefAndFlag;
94
+ const GlobalValueSummaryMapTy::value_type *Ref = nullptr ;
114
95
115
96
ValueInfo () = default ;
116
- ValueInfo (bool IsAnalysis, const GlobalValueSummaryMapTy::value_type *R) {
117
- RefAndFlag.setPointer (R);
118
- RefAndFlag.setInt (IsAnalysis);
119
- }
97
+ ValueInfo (const GlobalValueSummaryMapTy::value_type *Ref) : Ref(Ref) {}
120
98
121
- operator bool () const { return getRef () ; }
99
+ operator bool () const { return Ref ; }
122
100
123
- GlobalValue::GUID getGUID () const { return getRef ()->first ; }
124
- const GlobalValue *getValue () const {
125
- assert (isFromAnalysis ());
126
- return getRef ()->second .U .GV ;
127
- }
101
+ GlobalValue::GUID getGUID () const { return Ref->first ; }
102
+ const GlobalValue *getValue () const { return Ref->second .GV ; }
128
103
129
104
ArrayRef<std::unique_ptr<GlobalValueSummary>> getSummaryList () const {
130
- return getRef ()->second .SummaryList ;
131
- }
132
-
133
- StringRef name () const {
134
- return isFromAnalysis () ? getRef ()->second .U .GV ->getName ()
135
- : getRef ()->second .U .Name ;
136
- }
137
-
138
- bool isFromAnalysis () const { return RefAndFlag.getInt (); }
139
-
140
- const GlobalValueSummaryMapTy::value_type *getRef () const {
141
- return RefAndFlag.getPointer ();
105
+ return Ref->second .SummaryList ;
142
106
}
143
107
};
144
108
145
109
template <> struct DenseMapInfo <ValueInfo> {
146
110
static inline ValueInfo getEmptyKey () {
147
- return ValueInfo (false , (GlobalValueSummaryMapTy::value_type *)-8 );
111
+ return ValueInfo ((GlobalValueSummaryMapTy::value_type *)-1 );
148
112
}
149
113
150
114
static inline ValueInfo getTombstoneKey () {
151
- return ValueInfo (false , (GlobalValueSummaryMapTy::value_type *)-16 );
152
- }
153
-
154
- static inline bool isSpecialKey (ValueInfo V) {
155
- return V == getTombstoneKey () || V == getEmptyKey ();
115
+ return ValueInfo ((GlobalValueSummaryMapTy::value_type *)-2 );
156
116
}
157
117
158
- static bool isEqual (ValueInfo L, ValueInfo R) {
159
- // We are not supposed to mix ValueInfo(s) with different analysis flag
160
- // in a same container.
161
- assert (isSpecialKey (L) || isSpecialKey (R) ||
162
- (L.isFromAnalysis () == R.isFromAnalysis ()));
163
- return L.getRef () == R.getRef ();
164
- }
165
- static unsigned getHashValue (ValueInfo I) { return (uintptr_t )I.getRef (); }
118
+ static bool isEqual (ValueInfo L, ValueInfo R) { return L.Ref == R.Ref ; }
119
+ static unsigned getHashValue (ValueInfo I) { return (uintptr_t )I.Ref ; }
166
120
};
167
121
168
122
// / \brief Function and variable summary information to aid decisions and
@@ -665,11 +619,6 @@ class ModuleSummaryIndex {
665
619
// / considered live.
666
620
bool WithGlobalValueDeadStripping = false ;
667
621
668
- // / If true then we're performing analysis of IR module, filling summary
669
- // / accordingly. The value of 'false' means we're reading summary from
670
- // / BC or YAML source. Affects the type of value stored in NameOrGV union
671
- bool IsAnalysis;
672
-
673
622
std::set<std::string> CfiFunctionDefs;
674
623
std::set<std::string> CfiFunctionDecls;
675
624
@@ -678,16 +627,10 @@ class ModuleSummaryIndex {
678
627
679
628
GlobalValueSummaryMapTy::value_type *
680
629
getOrInsertValuePtr (GlobalValue::GUID GUID) {
681
- return &*GlobalValueMap.emplace (GUID, GlobalValueSummaryInfo (IsAnalysis) ).first ;
630
+ return &*GlobalValueMap.emplace (GUID, GlobalValueSummaryInfo{} ).first ;
682
631
}
683
632
684
633
public:
685
- // See IsAnalysis variable comment.
686
- ModuleSummaryIndex (bool IsPerformingAnalysis)
687
- : IsAnalysis(IsPerformingAnalysis) {}
688
-
689
- bool isPerformingAnalysis () const { return IsAnalysis; }
690
-
691
634
gvsummary_iterator begin () { return GlobalValueMap.begin (); }
692
635
const_gvsummary_iterator begin () const { return GlobalValueMap.begin (); }
693
636
gvsummary_iterator end () { return GlobalValueMap.end (); }
@@ -709,28 +652,19 @@ class ModuleSummaryIndex {
709
652
// / Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
710
653
ValueInfo getValueInfo (GlobalValue::GUID GUID) const {
711
654
auto I = GlobalValueMap.find (GUID);
712
- return ValueInfo (IsAnalysis, I == GlobalValueMap.end () ? nullptr : &*I);
655
+ return ValueInfo (I == GlobalValueMap.end () ? nullptr : &*I);
713
656
}
714
657
715
658
// / Return a ValueInfo for \p GUID.
716
659
ValueInfo getOrInsertValueInfo (GlobalValue::GUID GUID) {
717
- return ValueInfo (IsAnalysis, getOrInsertValuePtr (GUID));
718
- }
719
-
720
- // / Return a ValueInfo for \p GUID setting value \p Name.
721
- ValueInfo getOrInsertValueInfo (GlobalValue::GUID GUID, StringRef Name) {
722
- assert (!IsAnalysis);
723
- auto VP = getOrInsertValuePtr (GUID);
724
- VP->second .U .Name = Name;
725
- return ValueInfo (IsAnalysis, VP);
660
+ return ValueInfo (getOrInsertValuePtr (GUID));
726
661
}
727
662
728
663
// / Return a ValueInfo for \p GV and mark it as belonging to GV.
729
664
ValueInfo getOrInsertValueInfo (const GlobalValue *GV) {
730
- assert (IsAnalysis);
731
665
auto VP = getOrInsertValuePtr (GV->getGUID ());
732
- VP->second .U . GV = GV;
733
- return ValueInfo (IsAnalysis, VP);
666
+ VP->second .GV = GV;
667
+ return ValueInfo (VP);
734
668
}
735
669
736
670
// / Return the GUID for \p OriginalId in the OidGuidMap.
@@ -758,7 +692,7 @@ class ModuleSummaryIndex {
758
692
addOriginalName (VI.getGUID (), Summary->getOriginalName ());
759
693
// Here we have a notionally const VI, but the value it points to is owned
760
694
// by the non-const *this.
761
- const_cast <GlobalValueSummaryMapTy::value_type *>(VI.getRef () )
695
+ const_cast <GlobalValueSummaryMapTy::value_type *>(VI.Ref )
762
696
->second .SummaryList .push_back (std::move (Summary));
763
697
}
764
698
@@ -889,9 +823,6 @@ class ModuleSummaryIndex {
889
823
// / Summary).
890
824
void collectDefinedGVSummariesPerModule (
891
825
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries) const ;
892
-
893
- // / Export summary to dot file for GraphViz.
894
- void exportToDot (raw_ostream& OS) const ;
895
826
};
896
827
897
828
} // end namespace llvm
0 commit comments