@@ -134,16 +134,18 @@ class GlobalValueSummary {
134
134
// / be renamed or references something that can't be renamed).
135
135
unsigned NotEligibleToImport : 1 ;
136
136
137
- // / Indicate that the global value must be considered a live root for
138
- // / index-based liveness analysis. Used for special LLVM values such as
139
- // / llvm.global_ctors that the linker does not know about.
140
- unsigned LiveRoot : 1 ;
137
+ // / In per-module summary, indicate that the global value must be considered
138
+ // / a live root for index-based liveness analysis. Used for special LLVM
139
+ // / values such as llvm.global_ctors that the linker does not know about.
140
+ // /
141
+ // / In combined summary, indicate that the global value is live.
142
+ unsigned Live : 1 ;
141
143
142
144
// / Convenience Constructors
143
145
explicit GVFlags (GlobalValue::LinkageTypes Linkage,
144
- bool NotEligibleToImport, bool LiveRoot )
146
+ bool NotEligibleToImport, bool Live )
145
147
: Linkage(Linkage), NotEligibleToImport(NotEligibleToImport),
146
- LiveRoot(LiveRoot ) {}
148
+ Live(Live ) {}
147
149
};
148
150
149
151
private:
@@ -172,6 +174,8 @@ class GlobalValueSummary {
172
174
// / are listed in the derived FunctionSummary object.
173
175
std::vector<ValueInfo> RefEdgeList;
174
176
177
+ bool isLive () const { return Flags.Live ; }
178
+
175
179
protected:
176
180
GlobalValueSummary (SummaryKind K, GVFlags Flags, std::vector<ValueInfo> Refs)
177
181
: Kind(K), Flags(Flags), RefEdgeList(std::move(Refs)) {}
@@ -213,19 +217,17 @@ class GlobalValueSummary {
213
217
// / Return true if this global value can't be imported.
214
218
bool notEligibleToImport () const { return Flags.NotEligibleToImport ; }
215
219
216
- // / Return true if this global value must be considered a root for live
217
- // / value analysis on the index.
218
- bool liveRoot () const { return Flags.LiveRoot ; }
219
-
220
- // / Flag that this global value must be considered a root for live
221
- // / value analysis on the index.
222
- void setLiveRoot () { Flags.LiveRoot = true ; }
220
+ void setLive (bool Live) { Flags.Live = Live; }
223
221
224
222
// / Flag that this global value cannot be imported.
225
223
void setNotEligibleToImport () { Flags.NotEligibleToImport = true ; }
226
224
227
225
// / Return the list of values referenced by this global value definition.
228
226
ArrayRef<ValueInfo> refs () const { return RefEdgeList; }
227
+
228
+ friend class ModuleSummaryIndex ;
229
+ friend void computeDeadSymbols (class ModuleSummaryIndex &,
230
+ const DenseSet<GlobalValue::GUID> &);
229
231
};
230
232
231
233
// / \brief Alias summary information.
@@ -535,6 +537,11 @@ class ModuleSummaryIndex {
535
537
// / GUIDs, it will be mapped to 0.
536
538
std::map<GlobalValue::GUID, GlobalValue::GUID> OidGuidMap;
537
539
540
+ // / Indicates that summary-based GlobalValue GC has run, and values with
541
+ // / GVFlags::Live==false are really dead. Otherwise, all values must be
542
+ // / considered live.
543
+ bool WithGlobalValueDeadStripping = false ;
544
+
538
545
// YAML I/O support.
539
546
friend yaml::MappingTraits<ModuleSummaryIndex>;
540
547
@@ -550,6 +557,17 @@ class ModuleSummaryIndex {
550
557
const_gvsummary_iterator end () const { return GlobalValueMap.end (); }
551
558
size_t size () const { return GlobalValueMap.size (); }
552
559
560
+ bool withGlobalValueDeadStripping () const {
561
+ return WithGlobalValueDeadStripping;
562
+ }
563
+ void setWithGlobalValueDeadStripping () {
564
+ WithGlobalValueDeadStripping = true ;
565
+ }
566
+
567
+ bool isGlobalValueLive (const GlobalValueSummary *GVS) const {
568
+ return !WithGlobalValueDeadStripping || GVS->isLive ();
569
+ }
570
+
553
571
// / Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
554
572
ValueInfo getValueInfo (GlobalValue::GUID GUID) const {
555
573
auto I = GlobalValueMap.find (GUID);
0 commit comments