Skip to content

Commit 72b9bdb

Browse files
committed
Temporarily revert r323062 to investigate buildbot failures
llvm-svn: 323065
1 parent e076888 commit 72b9bdb

14 files changed

+31
-431
lines changed

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 19 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,9 @@ class GlobalValueSummary;
6969
using GlobalValueSummaryList = std::vector<std::unique_ptr<GlobalValueSummary>>;
7070

7171
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;
9375

9476
/// List of global value summary structures for a particular value held
9577
/// in the GlobalValueMap. Requires a vector in the case of multiple
@@ -109,60 +91,32 @@ using GlobalValueSummaryMapTy =
10991
/// Struct that holds a reference to a particular GUID in a global value
11092
/// summary.
11193
struct ValueInfo {
112-
PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 1, bool>
113-
RefAndFlag;
94+
const GlobalValueSummaryMapTy::value_type *Ref = nullptr;
11495

11596
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) {}
12098

121-
operator bool() const { return getRef(); }
99+
operator bool() const { return Ref; }
122100

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; }
128103

129104
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;
142106
}
143107
};
144108

145109
template <> struct DenseMapInfo<ValueInfo> {
146110
static inline ValueInfo getEmptyKey() {
147-
return ValueInfo(false, (GlobalValueSummaryMapTy::value_type *)-8);
111+
return ValueInfo((GlobalValueSummaryMapTy::value_type *)-1);
148112
}
149113

150114
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);
156116
}
157117

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; }
166120
};
167121

168122
/// \brief Function and variable summary information to aid decisions and
@@ -665,11 +619,6 @@ class ModuleSummaryIndex {
665619
/// considered live.
666620
bool WithGlobalValueDeadStripping = false;
667621

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-
673622
std::set<std::string> CfiFunctionDefs;
674623
std::set<std::string> CfiFunctionDecls;
675624

@@ -678,16 +627,10 @@ class ModuleSummaryIndex {
678627

679628
GlobalValueSummaryMapTy::value_type *
680629
getOrInsertValuePtr(GlobalValue::GUID GUID) {
681-
return &*GlobalValueMap.emplace(GUID, GlobalValueSummaryInfo(IsAnalysis)).first;
630+
return &*GlobalValueMap.emplace(GUID, GlobalValueSummaryInfo{}).first;
682631
}
683632

684633
public:
685-
// See IsAnalysis variable comment.
686-
ModuleSummaryIndex(bool IsPerformingAnalysis)
687-
: IsAnalysis(IsPerformingAnalysis) {}
688-
689-
bool isPerformingAnalysis() const { return IsAnalysis; }
690-
691634
gvsummary_iterator begin() { return GlobalValueMap.begin(); }
692635
const_gvsummary_iterator begin() const { return GlobalValueMap.begin(); }
693636
gvsummary_iterator end() { return GlobalValueMap.end(); }
@@ -709,28 +652,19 @@ class ModuleSummaryIndex {
709652
/// Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
710653
ValueInfo getValueInfo(GlobalValue::GUID GUID) const {
711654
auto I = GlobalValueMap.find(GUID);
712-
return ValueInfo(IsAnalysis, I == GlobalValueMap.end() ? nullptr : &*I);
655+
return ValueInfo(I == GlobalValueMap.end() ? nullptr : &*I);
713656
}
714657

715658
/// Return a ValueInfo for \p GUID.
716659
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));
726661
}
727662

728663
/// Return a ValueInfo for \p GV and mark it as belonging to GV.
729664
ValueInfo getOrInsertValueInfo(const GlobalValue *GV) {
730-
assert(IsAnalysis);
731665
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);
734668
}
735669

736670
/// Return the GUID for \p OriginalId in the OidGuidMap.
@@ -758,7 +692,7 @@ class ModuleSummaryIndex {
758692
addOriginalName(VI.getGUID(), Summary->getOriginalName());
759693
// Here we have a notionally const VI, but the value it points to is owned
760694
// by the non-const *this.
761-
const_cast<GlobalValueSummaryMapTy::value_type *>(VI.getRef())
695+
const_cast<GlobalValueSummaryMapTy::value_type *>(VI.Ref)
762696
->second.SummaryList.push_back(std::move(Summary));
763697
}
764698

@@ -889,9 +823,6 @@ class ModuleSummaryIndex {
889823
/// Summary).
890824
void collectDefinedGVSummariesPerModule(
891825
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries) const;
892-
893-
/// Export summary to dot file for GraphViz.
894-
void exportToDot(raw_ostream& OS) const;
895826
};
896827

897828
} // end namespace llvm

llvm/include/llvm/IR/ModuleSummaryIndexYAML.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ template <> struct CustomMappingTraits<GlobalValueSummaryMapTy> {
207207
io.setError("key not an integer");
208208
return;
209209
}
210-
auto P = V.emplace(KeyInt, /*IsAnalysis=*/false);
211-
auto &Elem = (*P.first).second;
210+
auto &Elem = V[KeyInt];
212211
for (auto &FSum : FSums) {
213212
Elem.SummaryList.push_back(llvm::make_unique<FunctionSummary>(
214213
GlobalValueSummary::GVFlags(

llvm/lib/Analysis/ModuleSummaryAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex(
372372
std::function<BlockFrequencyInfo *(const Function &F)> GetBFICallback,
373373
ProfileSummaryInfo *PSI) {
374374
assert(PSI);
375-
ModuleSummaryIndex Index(/*IsPerformingAnalysis=*/true);
375+
ModuleSummaryIndex Index;
376376

377377
// Identify the local values in the llvm.used and llvm.compiler.used sets,
378378
// which should not be exported as they would then require renaming and

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4813,12 +4813,8 @@ void ModuleSummaryIndexBitcodeReader::setValueGUID(
48134813
if (PrintSummaryGUIDs)
48144814
dbgs() << "GUID " << ValueGUID << "(" << OriginalNameID << ") is "
48154815
<< ValueName << "\n";
4816-
4817-
// UseStrtab is false for legacy summary formats and value names are
4818-
// created on stack. We can't use them outside of parseValueSymbolTable.
4819-
ValueIdToValueInfoMap[ValueID] = std::make_pair(
4820-
TheIndex.getOrInsertValueInfo(ValueGUID, UseStrtab ? ValueName : ""),
4821-
OriginalNameID);
4816+
ValueIdToValueInfoMap[ValueID] =
4817+
std::make_pair(TheIndex.getOrInsertValueInfo(ValueGUID), OriginalNameID);
48224818
}
48234819

48244820
// Specialized value symbol table parser used when reading module index
@@ -5683,8 +5679,7 @@ Expected<std::unique_ptr<ModuleSummaryIndex>> BitcodeModule::getSummary() {
56835679
BitstreamCursor Stream(Buffer);
56845680
Stream.JumpToBit(ModuleBit);
56855681

5686-
auto Index =
5687-
llvm::make_unique<ModuleSummaryIndex>(/*IsPerformingAnalysis=*/false);
5682+
auto Index = llvm::make_unique<ModuleSummaryIndex>();
56885683
ModuleSummaryIndexBitcodeReader R(std::move(Stream), Strtab, *Index,
56895684
ModuleIdentifier, 0);
56905685

0 commit comments

Comments
 (0)