[llvm] r365097 - Revert [ThinLTO] Optimize writeonly globals out
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 17:03:31 PDT 2019
Author: rnk
Date: Wed Jul 3 17:03:30 2019
New Revision: 365097
URL: http://llvm.org/viewvc/llvm-project?rev=365097&view=rev
Log:
Revert [ThinLTO] Optimize writeonly globals out
This reverts r365040 (git commit 5cacb914758c7f436b47c8362100f10cef14bbc4)
Speculatively reverting, since this appears to have broken check-lld on
Linux. Partial analysis in https://crbug.com/981168.
Removed:
llvm/trunk/test/ThinLTO/X86/Inputs/dot-dumper2.ll
llvm/trunk/test/ThinLTO/X86/dot-dumper2.ll
llvm/trunk/test/ThinLTO/X86/writeonly.ll
llvm/trunk/test/ThinLTO/X86/writeonly2.ll
Modified:
llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/IR/AsmWriter.cpp
llvm/trunk/lib/IR/ModuleSummaryIndex.cpp
llvm/trunk/lib/LTO/LTO.cpp
llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
llvm/trunk/test/Assembler/thinlto-summary.ll
llvm/trunk/test/Assembler/thinlto-vtable-summary.ll
llvm/trunk/test/Bitcode/summary_version.ll
llvm/trunk/test/Bitcode/thinlto-alias.ll
llvm/trunk/test/Bitcode/thinlto-alias2.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-cast.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-relbf.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll
llvm/trunk/test/Bitcode/thinlto-function-summary-refgraph.ll
llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll
Modified: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h (original)
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h Wed Jul 3 17:03:30 2019
@@ -162,8 +162,7 @@ using GlobalValueSummaryMapTy =
/// Struct that holds a reference to a particular GUID in a global value
/// summary.
struct ValueInfo {
- enum Flags { HaveGV = 1, ReadOnly = 2, WriteOnly = 4 };
- PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 3, int>
+ PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 2, int>
RefAndFlags;
ValueInfo() = default;
@@ -189,33 +188,9 @@ struct ValueInfo {
: getRef()->second.U.Name;
}
- bool haveGVs() const { return RefAndFlags.getInt() & HaveGV; }
- bool isReadOnly() const {
- assert(isValidAccessSpecifier());
- return RefAndFlags.getInt() & ReadOnly;
- }
- bool isWriteOnly() const {
- assert(isValidAccessSpecifier());
- return RefAndFlags.getInt() & WriteOnly;
- }
- unsigned getAccessSpecifier() const {
- assert(isValidAccessSpecifier());
- return RefAndFlags.getInt() & (ReadOnly | WriteOnly);
- }
- bool isValidAccessSpecifier() const {
- unsigned BadAccessMask = ReadOnly | WriteOnly;
- return (RefAndFlags.getInt() & BadAccessMask) != BadAccessMask;
- }
- void setReadOnly() {
- // We expect ro/wo attribute to set only once during
- // ValueInfo lifetime.
- assert(getAccessSpecifier() == 0);
- RefAndFlags.setInt(RefAndFlags.getInt() | ReadOnly);
- }
- void setWriteOnly() {
- assert(getAccessSpecifier() == 0);
- RefAndFlags.setInt(RefAndFlags.getInt() | WriteOnly);
- }
+ bool haveGVs() const { return RefAndFlags.getInt() & 0x1; }
+ bool isReadOnly() const { return RefAndFlags.getInt() & 0x2; }
+ void setReadOnly() { RefAndFlags.setInt(RefAndFlags.getInt() | 0x2); }
const GlobalValueSummaryMapTy::value_type *getRef() const {
return RefAndFlags.getPointer();
@@ -609,8 +584,8 @@ public:
std::move(TypeTestAssumeConstVCalls),
std::move(TypeCheckedLoadConstVCalls)});
}
- // Gets the number of readonly and writeonly refs in RefEdgeList
- std::pair<unsigned, unsigned> specialRefCounts() const;
+ // Gets the number of immutable refs in RefEdgeList
+ unsigned immutableRefCount() const;
/// Check if this is a function summary.
static bool classof(const GlobalValueSummary *GVS) {
@@ -738,12 +713,9 @@ using VTableFuncList = std::vector<VirtF
/// Global variable summary information to aid decisions and
/// implementation of importing.
///
-/// Global variable summary has two extra flag, telling if it is
-/// readonly or writeonly. Both readonly and writeonly variables
-/// can be optimized in the backed: readonly variables can be
-/// const-folded, while writeonly vars can be completely eliminated
-/// together with corresponding stores. We let both things happen
-/// by means of internalizing such variables after ThinLTO import.
+/// Global variable summary has extra flag, telling if it is
+/// modified during the program run or not. This affects ThinLTO
+/// internalization
class GlobalVarSummary : public GlobalValueSummary {
private:
/// For vtable definitions this holds the list of functions and
@@ -752,14 +724,9 @@ private:
public:
struct GVarFlags {
- GVarFlags(bool ReadOnly, bool WriteOnly)
- : MaybeReadOnly(ReadOnly), MaybeWriteOnly(WriteOnly) {}
+ GVarFlags(bool ReadOnly = false) : ReadOnly(ReadOnly) {}
- // In permodule summaries both MaybeReadOnly and MaybeWriteOnly
- // bits are set, because attribute propagation occurs later on
- // thin link phase.
- unsigned MaybeReadOnly : 1;
- unsigned MaybeWriteOnly : 1;
+ unsigned ReadOnly : 1;
} VarFlags;
GlobalVarSummary(GVFlags Flags, GVarFlags VarFlags,
@@ -773,10 +740,8 @@ public:
}
GVarFlags varflags() const { return VarFlags; }
- void setReadOnly(bool RO) { VarFlags.MaybeReadOnly = RO; }
- void setWriteOnly(bool WO) { VarFlags.MaybeWriteOnly = WO; }
- bool maybeReadOnly() const { return VarFlags.MaybeReadOnly; }
- bool maybeWriteOnly() const { return VarFlags.MaybeWriteOnly; }
+ void setReadOnly(bool RO) { VarFlags.ReadOnly = RO; }
+ bool isReadOnly() const { return VarFlags.ReadOnly; }
void setVTableFuncs(VTableFuncList Funcs) {
assert(!VTableFuncs);
@@ -1347,7 +1312,7 @@ public:
void dumpSCCs(raw_ostream &OS);
/// Analyze index and detect unmodified globals
- void propagateAttributes(const DenseSet<GlobalValue::GUID> &PreservedSymbols);
+ void propagateConstants(const DenseSet<GlobalValue::GUID> &PreservedSymbols);
};
/// GraphTraits definition to build SCC for the index
Modified: llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp Wed Jul 3 17:03:30 2019
@@ -231,13 +231,6 @@ static bool isNonVolatileLoad(const Inst
return false;
}
-static bool isNonVolatileStore(const Instruction *I) {
- if (const auto *SI = dyn_cast<StoreInst>(I))
- return !SI->isVolatile();
-
- return false;
-}
-
static void computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M,
const Function &F, BlockFrequencyInfo *BFI,
ProfileSummaryInfo *PSI, DominatorTree &DT,
@@ -252,7 +245,7 @@ static void computeFunctionSummary(Modul
// Map from callee ValueId to profile count. Used to accumulate profile
// counts for all static calls to a given callee.
MapVector<ValueInfo, CalleeInfo> CallGraphEdges;
- SetVector<ValueInfo> RefEdges, LoadRefEdges, StoreRefEdges;
+ SetVector<ValueInfo> RefEdges;
SetVector<GlobalValue::GUID> TypeTests;
SetVector<FunctionSummary::VFuncId> TypeTestAssumeVCalls,
TypeCheckedLoadVCalls;
@@ -265,7 +258,6 @@ static void computeFunctionSummary(Modul
// list.
findRefEdges(Index, &F, RefEdges, Visited);
std::vector<const Instruction *> NonVolatileLoads;
- std::vector<const Instruction *> NonVolatileStores;
bool HasInlineAsmMaybeReferencingInternal = false;
for (const BasicBlock &BB : F)
@@ -273,34 +265,12 @@ static void computeFunctionSummary(Modul
if (isa<DbgInfoIntrinsic>(I))
continue;
++NumInsts;
- // Regular LTO module doesn't participate in ThinLTO import,
- // so no reference from it can be read/writeonly, since this
- // would require importing variable as local copy
- if (IsThinLTO) {
- if (isNonVolatileLoad(&I)) {
- // Postpone processing of non-volatile load instructions
- // See comments below
- Visited.insert(&I);
- NonVolatileLoads.push_back(&I);
- continue;
- } else if (isNonVolatileStore(&I)) {
- Visited.insert(&I);
- NonVolatileStores.push_back(&I);
- // All references from second operand of store (destination address)
- // can be considered write-only if they're not referenced by any
- // non-store instruction. References from first operand of store
- // (stored value) can't be treated either as read- or as write-only
- // so we add them to RefEdges as we do with all other instructions
- // except non-volatile load.
- Value *Stored = I.getOperand(0);
- if (auto *GV = dyn_cast<GlobalValue>(Stored))
- // findRefEdges will try to examine GV operands, so instead
- // of calling it we should add GV to RefEdges directly.
- RefEdges.insert(Index.getOrInsertValueInfo(GV));
- else if (auto *U = dyn_cast<User>(Stored))
- findRefEdges(Index, U, RefEdges, Visited);
- continue;
- }
+ if (isNonVolatileLoad(&I)) {
+ // Postpone processing of non-volatile load instructions
+ // See comments below
+ Visited.insert(&I);
+ NonVolatileLoads.push_back(&I);
+ continue;
}
findRefEdges(Index, &I, RefEdges, Visited);
auto CS = ImmutableCallSite(&I);
@@ -391,49 +361,24 @@ static void computeFunctionSummary(Modul
}
}
- std::vector<ValueInfo> Refs;
- if (IsThinLTO) {
- auto AddRefEdges = [&](const std::vector<const Instruction *> &Instrs,
- SetVector<ValueInfo> &Edges) {
- for (const auto *I : Instrs) {
- Visited.erase(I);
- findRefEdges(Index, I, Edges, Visited);
- }
- };
-
- // By now we processed all instructions in a function, except
- // non-volatile loads and non-volatile value stores. Let's find
- // ref edges for both of instruction sets
- AddRefEdges(NonVolatileLoads, LoadRefEdges);
- AddRefEdges(NonVolatileStores, StoreRefEdges);
-
- // If both load and store instruction reference the same variable
- // we won't be able to optimize it. Add all such reference edges
- // to RefEdges set.
- for (auto &VI : StoreRefEdges)
- if (LoadRefEdges.remove(VI))
- RefEdges.insert(VI);
-
- unsigned RefCnt = RefEdges.size();
- // All new reference edges inserted in two loops below are either
- // read or write only. They will be grouped in the end of RefEdges
- // vector, so we can use a single integer value to identify them.
- for (auto &VI : LoadRefEdges)
- RefEdges.insert(VI);
-
- unsigned FirstWORef = RefEdges.size();
- for (auto &VI : StoreRefEdges)
- RefEdges.insert(VI);
-
- Refs = RefEdges.takeVector();
- for (; RefCnt < FirstWORef; ++RefCnt)
+ // By now we processed all instructions in a function, except
+ // non-volatile loads. All new refs we add in a loop below
+ // are obviously constant. All constant refs are grouped in the
+ // end of RefEdges vector, so we can use a single integer value
+ // to identify them.
+ unsigned RefCnt = RefEdges.size();
+ for (const Instruction *I : NonVolatileLoads) {
+ Visited.erase(I);
+ findRefEdges(Index, I, RefEdges, Visited);
+ }
+ std::vector<ValueInfo> Refs = RefEdges.takeVector();
+ // Regular LTO module doesn't participate in ThinLTO import,
+ // so no reference from it can be readonly, since this would
+ // require importing variable as local copy
+ if (IsThinLTO)
+ for (; RefCnt < Refs.size(); ++RefCnt)
Refs[RefCnt].setReadOnly();
- for (; RefCnt < Refs.size(); ++RefCnt)
- Refs[RefCnt].setWriteOnly();
- } else {
- Refs = RefEdges.takeVector();
- }
// Explicit add hot edges to enforce importing for designated GUIDs for
// sample PGO, to enable the same inlines as the profiled optimized binary.
for (auto &I : F.getImportGUIDs())
@@ -581,11 +526,10 @@ static void computeVariableSummary(Modul
}
}
- // Don't mark variables we won't be able to internalize as read/write-only.
- bool CanBeInternalized =
+ // Don't mark variables we won't be able to internalize as read-only.
+ GlobalVarSummary::GVarFlags VarFlags(
!V.hasComdat() && !V.hasAppendingLinkage() && !V.isInterposable() &&
- !V.hasAvailableExternallyLinkage() && !V.hasDLLExportStorageClass();
- GlobalVarSummary::GVarFlags VarFlags(CanBeInternalized, CanBeInternalized);
+ !V.hasAvailableExternallyLinkage() && !V.hasDLLExportStorageClass());
auto GVarSummary = llvm::make_unique<GlobalVarSummary>(Flags, VarFlags,
RefEdges.takeVector());
if (NonRenamableLocal)
@@ -703,7 +647,7 @@ ModuleSummaryIndex llvm::buildModuleSumm
} else {
std::unique_ptr<GlobalVarSummary> Summary =
llvm::make_unique<GlobalVarSummary>(
- GVFlags, GlobalVarSummary::GVarFlags(false, false),
+ GVFlags, GlobalVarSummary::GVarFlags(),
ArrayRef<ValueInfo>{});
Index.addGlobalValueSummary(*GV, std::move(Summary));
}
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Jul 3 17:03:30 2019
@@ -7849,13 +7849,9 @@ static const auto FwdVIRef = (GlobalValu
static void resolveFwdRef(ValueInfo *Fwd, ValueInfo &Resolved) {
bool ReadOnly = Fwd->isReadOnly();
- bool WriteOnly = Fwd->isWriteOnly();
- assert(!(ReadOnly && WriteOnly));
*Fwd = Resolved;
if (ReadOnly)
Fwd->setReadOnly();
- if (WriteOnly)
- Fwd->setWriteOnly();
}
/// Stores the given Name/GUID and associated summary into the Index.
@@ -8085,8 +8081,7 @@ bool LLParser::ParseVariableSummary(std:
GlobalValueSummary::GVFlags GVFlags = GlobalValueSummary::GVFlags(
/*Linkage=*/GlobalValue::ExternalLinkage, /*NotEligibleToImport=*/false,
/*Live=*/false, /*IsLocal=*/false, /*CanAutoHide=*/false);
- GlobalVarSummary::GVarFlags GVarFlags(/*ReadOnly*/ false,
- /* WriteOnly */ false);
+ GlobalVarSummary::GVarFlags GVarFlags(/*ReadOnly*/ false);
std::vector<ValueInfo> Refs;
VTableFuncList VTableFuncs;
if (ParseToken(lltok::colon, "expected ':' here") ||
@@ -8427,11 +8422,10 @@ bool LLParser::ParseOptionalRefs(std::ve
VContexts.push_back(VC);
} while (EatIfPresent(lltok::comma));
- // Sort value contexts so that ones with writeonly
- // and readonly ValueInfo are at the end of VContexts vector.
- // See FunctionSummary::specialRefCounts()
+ // Sort value contexts so that ones with readonly ValueInfo are at the end
+ // of VContexts vector. This is needed to match immutableRefCount() behavior.
llvm::sort(VContexts, [](const ValueContext &VC1, const ValueContext &VC2) {
- return VC1.VI.getAccessSpecifier() < VC2.VI.getAccessSpecifier();
+ return VC1.VI.isReadOnly() < VC2.VI.isReadOnly();
});
IdToIndexMapType IdToIndexMap;
@@ -8749,41 +8743,24 @@ bool LLParser::ParseGVFlags(GlobalValueS
}
/// GVarFlags
-/// ::= 'varFlags' ':' '(' 'readonly' ':' Flag
-/// ',' 'writeonly' ':' Flag ')'
+/// ::= 'varFlags' ':' '(' 'readonly' ':' Flag ')'
bool LLParser::ParseGVarFlags(GlobalVarSummary::GVarFlags &GVarFlags) {
assert(Lex.getKind() == lltok::kw_varFlags);
Lex.Lex();
+ unsigned Flag = 0;
if (ParseToken(lltok::colon, "expected ':' here") ||
- ParseToken(lltok::lparen, "expected '(' here"))
+ ParseToken(lltok::lparen, "expected '(' here") ||
+ ParseToken(lltok::kw_readonly, "expected 'readonly' here") ||
+ ParseToken(lltok::colon, "expected ':' here"))
return true;
- auto ParseRest = [this](unsigned int &Val) {
- Lex.Lex();
- if (ParseToken(lltok::colon, "expected ':'"))
- return true;
- return ParseFlag(Val);
- };
+ ParseFlag(Flag);
+ GVarFlags.ReadOnly = Flag;
- do {
- unsigned Flag = 0;
- switch (Lex.getKind()) {
- case lltok::kw_readonly:
- if (ParseRest(Flag))
- return true;
- GVarFlags.MaybeReadOnly = Flag;
- break;
- case lltok::kw_writeonly:
- if (ParseRest(Flag))
- return true;
- GVarFlags.MaybeWriteOnly = Flag;
- break;
- default:
- return Error(Lex.getLoc(), "expected gvar flag type");
- }
- } while (EatIfPresent(lltok::comma));
- return ParseToken(lltok::rparen, "expected ')' here");
+ if (ParseToken(lltok::rparen, "expected ')' here"))
+ return true;
+ return false;
}
/// ModuleReference
@@ -8806,9 +8783,7 @@ bool LLParser::ParseModuleReference(Stri
/// GVReference
/// ::= SummaryID
bool LLParser::ParseGVReference(ValueInfo &VI, unsigned &GVId) {
- bool WriteOnly = false, ReadOnly = EatIfPresent(lltok::kw_readonly);
- if (!ReadOnly)
- WriteOnly = EatIfPresent(lltok::kw_writeonly);
+ bool ReadOnly = EatIfPresent(lltok::kw_readonly);
if (ParseToken(lltok::SummaryID, "expected GV ID"))
return true;
@@ -8823,7 +8798,5 @@ bool LLParser::ParseGVReference(ValueInf
if (ReadOnly)
VI.setReadOnly();
- if (WriteOnly)
- VI.setWriteOnly();
return false;
}
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Jul 3 17:03:30 2019
@@ -984,8 +984,7 @@ static GlobalValueSummary::GVFlags getDe
// Decode the flags for GlobalVariable in the summary
static GlobalVarSummary::GVarFlags getDecodedGVarFlags(uint64_t RawFlags) {
- return GlobalVarSummary::GVarFlags((RawFlags & 0x1) ? true : false,
- (RawFlags & 0x2) ? true : false);
+ return GlobalVarSummary::GVarFlags((RawFlags & 0x1) ? true : false);
}
static GlobalValue::VisibilityTypes getDecodedVisibility(unsigned Val) {
@@ -5682,16 +5681,10 @@ void ModuleSummaryIndexBitcodeReader::pa
parseTypeIdCompatibleVtableInfo(Record, Slot, TypeId);
}
-static void setSpecialRefs(std::vector<ValueInfo> &Refs, unsigned ROCnt,
- unsigned WOCnt) {
- // Readonly and writeonly refs are in the end of the refs list.
- assert(ROCnt + WOCnt <= Refs.size());
- unsigned FirstWORef = Refs.size() - WOCnt;
- unsigned RefNo = FirstWORef - ROCnt;
- for (; RefNo < FirstWORef; ++RefNo)
+static void setImmutableRefs(std::vector<ValueInfo> &Refs, unsigned Count) {
+ // Read-only refs are in the end of the refs list.
+ for (unsigned RefNo = Refs.size() - Count; RefNo < Refs.size(); ++RefNo)
Refs[RefNo].setReadOnly();
- for (; RefNo < Refs.size(); ++RefNo)
- Refs[RefNo].setWriteOnly();
}
// Eagerly parse the entire summary block. This populates the GlobalValueSummary
@@ -5718,9 +5711,9 @@ Error ModuleSummaryIndexBitcodeReader::p
}
const uint64_t Version = Record[0];
const bool IsOldProfileFormat = Version == 1;
- if (Version < 1 || Version > 7)
+ if (Version < 1 || Version > 6)
return error("Invalid summary version " + Twine(Version) +
- ". Version should be in the range [1-7].");
+ ". Version should be in the range [1-6].");
Record.clear();
// Keep around the last seen summary to be used when we see an optional
@@ -5819,19 +5812,15 @@ Error ModuleSummaryIndexBitcodeReader::p
unsigned InstCount = Record[2];
uint64_t RawFunFlags = 0;
unsigned NumRefs = Record[3];
- unsigned NumRORefs = 0, NumWORefs = 0;
+ unsigned NumImmutableRefs = 0;
int RefListStartIndex = 4;
if (Version >= 4) {
RawFunFlags = Record[3];
NumRefs = Record[4];
RefListStartIndex = 5;
if (Version >= 5) {
- NumRORefs = Record[5];
+ NumImmutableRefs = Record[5];
RefListStartIndex = 6;
- if (Version >= 7) {
- NumWORefs = Record[6];
- RefListStartIndex = 7;
- }
}
}
@@ -5851,7 +5840,7 @@ Error ModuleSummaryIndexBitcodeReader::p
std::vector<FunctionSummary::EdgeTy> Calls = makeCallList(
ArrayRef<uint64_t>(Record).slice(CallGraphEdgeStartIndex),
IsOldProfileFormat, HasProfile, HasRelBF);
- setSpecialRefs(Refs, NumRORefs, NumWORefs);
+ setImmutableRefs(Refs, NumImmutableRefs);
auto FS = llvm::make_unique<FunctionSummary>(
Flags, InstCount, getDecodedFFlags(RawFunFlags), /*EntryCount=*/0,
std::move(Refs), std::move(Calls), std::move(PendingTypeTests),
@@ -5902,8 +5891,7 @@ Error ModuleSummaryIndexBitcodeReader::p
unsigned ValueID = Record[0];
uint64_t RawFlags = Record[1];
unsigned RefArrayStart = 2;
- GlobalVarSummary::GVarFlags GVF(/* ReadOnly */ false,
- /* WriteOnly */ false);
+ GlobalVarSummary::GVarFlags GVF;
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
if (Version >= 5) {
GVF = getDecodedGVarFlags(Record[2]);
@@ -5960,7 +5948,7 @@ Error ModuleSummaryIndexBitcodeReader::p
uint64_t RawFunFlags = 0;
uint64_t EntryCount = 0;
unsigned NumRefs = Record[4];
- unsigned NumRORefs = 0, NumWORefs = 0;
+ unsigned NumImmutableRefs = 0;
int RefListStartIndex = 5;
if (Version >= 4) {
@@ -5968,19 +5956,13 @@ Error ModuleSummaryIndexBitcodeReader::p
RefListStartIndex = 6;
size_t NumRefsIndex = 5;
if (Version >= 5) {
- unsigned NumRORefsOffset = 1;
RefListStartIndex = 7;
if (Version >= 6) {
NumRefsIndex = 6;
EntryCount = Record[5];
RefListStartIndex = 8;
- if (Version >= 7) {
- RefListStartIndex = 9;
- NumWORefs = Record[8];
- NumRORefsOffset = 2;
- }
}
- NumRORefs = Record[RefListStartIndex - NumRORefsOffset];
+ NumImmutableRefs = Record[RefListStartIndex - 1];
}
NumRefs = Record[NumRefsIndex];
}
@@ -5996,7 +5978,7 @@ Error ModuleSummaryIndexBitcodeReader::p
ArrayRef<uint64_t>(Record).slice(CallGraphEdgeStartIndex),
IsOldProfileFormat, HasProfile, false);
ValueInfo VI = getValueInfoFromValueId(ValueID).first;
- setSpecialRefs(Refs, NumRORefs, NumWORefs);
+ setImmutableRefs(Refs, NumImmutableRefs);
auto FS = llvm::make_unique<FunctionSummary>(
Flags, InstCount, getDecodedFFlags(RawFunFlags), EntryCount,
std::move(Refs), std::move(Edges), std::move(PendingTypeTests),
@@ -6043,8 +6025,7 @@ Error ModuleSummaryIndexBitcodeReader::p
uint64_t ModuleId = Record[1];
uint64_t RawFlags = Record[2];
unsigned RefArrayStart = 3;
- GlobalVarSummary::GVarFlags GVF(/* ReadOnly */ false,
- /* WriteOnly */ false);
+ GlobalVarSummary::GVarFlags GVF;
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
if (Version >= 5) {
GVF = getDecodedGVarFlags(Record[3]);
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Wed Jul 3 17:03:30 2019
@@ -1017,7 +1017,7 @@ static uint64_t getEncodedGVSummaryFlags
}
static uint64_t getEncodedGVarFlags(GlobalVarSummary::GVarFlags Flags) {
- uint64_t RawFlags = Flags.MaybeReadOnly | (Flags.MaybeWriteOnly << 1);
+ uint64_t RawFlags = Flags.ReadOnly;
return RawFlags;
}
@@ -3629,13 +3629,11 @@ void ModuleBitcodeWriterBase::writePerMo
FunctionSummary *FS = cast<FunctionSummary>(Summary);
writeFunctionTypeMetadataRecords(Stream, FS);
- auto SpecialRefCnts = FS->specialRefCounts();
NameVals.push_back(getEncodedGVSummaryFlags(FS->flags()));
NameVals.push_back(FS->instCount());
NameVals.push_back(getEncodedFFlags(FS->fflags()));
NameVals.push_back(FS->refs().size());
- NameVals.push_back(SpecialRefCnts.first); // rorefcnt
- NameVals.push_back(SpecialRefCnts.second); // worefcnt
+ NameVals.push_back(FS->immutableRefCount());
for (auto &RI : FS->refs())
NameVals.push_back(VE.getValueID(RI.getValue()));
@@ -3709,7 +3707,7 @@ void ModuleBitcodeWriterBase::writeModul
// Current version for the summary.
// This is bumped whenever we introduce changes in the way some record are
// interpreted, like flags for instance.
-static const uint64_t INDEX_VERSION = 7;
+static const uint64_t INDEX_VERSION = 6;
/// Emit the per-module summary section alongside the rest of
/// the module's bitcode.
@@ -3751,8 +3749,7 @@ void ModuleBitcodeWriterBase::writePerMo
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // fflags
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // rorefcnt
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // worefcnt
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // immutablerefcnt
// numrefs x valueid, n x (valueid, hotness)
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
@@ -3769,8 +3766,7 @@ void ModuleBitcodeWriterBase::writePerMo
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // fflags
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // rorefcnt
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // worefcnt
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // immutablerefcnt
// numrefs x valueid, n x (valueid [, rel_block_freq])
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
@@ -3902,8 +3898,7 @@ void IndexBitcodeWriter::writeCombinedGl
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // fflags
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // entrycount
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // rorefcnt
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // worefcnt
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // immutablerefcnt
// numrefs x valueid, n x (valueid)
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
@@ -3919,8 +3914,7 @@ void IndexBitcodeWriter::writeCombinedGl
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // fflags
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // entrycount
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // rorefcnt
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // worefcnt
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // immutablerefcnt
// numrefs x valueid, n x (valueid, hotness)
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
@@ -4022,24 +4016,20 @@ void IndexBitcodeWriter::writeCombinedGl
// Fill in below
NameVals.push_back(0); // numrefs
- NameVals.push_back(0); // rorefcnt
- NameVals.push_back(0); // worefcnt
+ NameVals.push_back(0); // immutablerefcnt
- unsigned Count = 0, RORefCnt = 0, WORefCnt = 0;
+ unsigned Count = 0, ImmutableRefCnt = 0;
for (auto &RI : FS->refs()) {
auto RefValueId = getValueId(RI.getGUID());
if (!RefValueId)
continue;
NameVals.push_back(*RefValueId);
if (RI.isReadOnly())
- RORefCnt++;
- else if (RI.isWriteOnly())
- WORefCnt++;
+ ImmutableRefCnt++;
Count++;
}
NameVals[6] = Count;
- NameVals[7] = RORefCnt;
- NameVals[8] = WORefCnt;
+ NameVals[7] = ImmutableRefCnt;
bool HasProfileData = false;
for (auto &EI : FS->calls()) {
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Wed Jul 3 17:03:30 2019
@@ -2888,8 +2888,7 @@ void AssemblyWriter::printAliasSummary(c
}
void AssemblyWriter::printGlobalVarSummary(const GlobalVarSummary *GS) {
- Out << ", varFlags: (readonly: " << GS->VarFlags.MaybeReadOnly << ", "
- << "writeonly: " << GS->VarFlags.MaybeWriteOnly << ")";
+ Out << ", varFlags: (readonly: " << GS->VarFlags.ReadOnly << ")";
auto VTableFuncs = GS->vTableFuncs();
if (!VTableFuncs.empty()) {
@@ -3099,8 +3098,6 @@ void AssemblyWriter::printSummary(const
Out << FS;
if (Ref.isReadOnly())
Out << "readonly ";
- else if (Ref.isWriteOnly())
- Out << "writeonly ";
Out << "^" << Machine.getGUIDSlot(Ref.getGUID());
}
Out << ")";
Modified: llvm/trunk/lib/IR/ModuleSummaryIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ModuleSummaryIndex.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ModuleSummaryIndex.cpp (original)
+++ llvm/trunk/lib/IR/ModuleSummaryIndex.cpp Wed Jul 3 17:03:30 2019
@@ -23,8 +23,6 @@ using namespace llvm;
STATISTIC(ReadOnlyLiveGVars,
"Number of live global variables marked read only");
-STATISTIC(WriteOnlyLiveGVars,
- "Number of live global variables marked write only");
FunctionSummary FunctionSummary::ExternalNode =
FunctionSummary::makeDummyFunctionSummary({});
@@ -47,18 +45,15 @@ bool ValueInfo::canAutoHide() const {
});
}
-// Gets the number of readonly and writeonly refs in RefEdgeList
-std::pair<unsigned, unsigned> FunctionSummary::specialRefCounts() const {
- // Here we take advantage of having all readonly and writeonly references
+// Gets the number of immutable refs in RefEdgeList
+unsigned FunctionSummary::immutableRefCount() const {
+ // Here we take advantage of having all readonly references
// located in the end of the RefEdgeList.
auto Refs = refs();
- unsigned RORefCnt = 0, WORefCnt = 0;
- int I;
- for (I = Refs.size() - 1; I >= 0 && Refs[I].isWriteOnly(); --I)
- WORefCnt++;
- for (; I >= 0 && Refs[I].isReadOnly(); --I)
- RORefCnt++;
- return {RORefCnt, WORefCnt};
+ unsigned ImmutableRefCnt = 0;
+ for (int I = Refs.size() - 1; I >= 0 && Refs[I].isReadOnly(); --I)
+ ImmutableRefCnt++;
+ return ImmutableRefCnt;
}
// Collect for the given module the list of function it defines
@@ -104,56 +99,48 @@ bool ModuleSummaryIndex::isGUIDLive(Glob
return false;
}
-static void propagateAttributesToRefs(GlobalValueSummary *S) {
- // If reference is not readonly or writeonly then referenced summary is not
- // read/writeonly either. Note that:
+static void propagateConstantsToRefs(GlobalValueSummary *S) {
+ // If reference is not readonly then referenced summary is not
+ // readonly either. Note that:
// - All references from GlobalVarSummary are conservatively considered as
- // not readonly or writeonly. Tracking them properly requires more complex
- // analysis then we have now.
+ // not readonly. Tracking them properly requires more complex analysis
+ // then we have now.
//
// - AliasSummary objects have no refs at all so this function is a no-op
// for them.
for (auto &VI : S->refs()) {
- assert(VI.getAccessSpecifier() == 0 || isa<FunctionSummary>(S));
+ if (VI.isReadOnly()) {
+ // We only mark refs as readonly when computing function summaries on
+ // analysis phase.
+ assert(isa<FunctionSummary>(S));
+ continue;
+ }
for (auto &Ref : VI.getSummaryList())
- // If references to alias is not read/writeonly then aliasee
- // is not read/writeonly
- if (auto *GVS = dyn_cast<GlobalVarSummary>(Ref->getBaseObject())) {
- if (!VI.isReadOnly())
- GVS->setReadOnly(false);
- if (!VI.isWriteOnly())
- GVS->setWriteOnly(false);
- }
+ // If references to alias is not readonly then aliasee is not readonly
+ if (auto *GVS = dyn_cast<GlobalVarSummary>(Ref->getBaseObject()))
+ GVS->setReadOnly(false);
}
}
-// Do the access attribute propagation in combined index.
-// The goal of attribute propagation is internalization of readonly (RO)
-// or writeonly (WO) variables. To determine which variables are RO or WO
-// and which are not we take following steps:
-// - During analysis we speculatively assign readonly and writeonly
-// attribute to all variables which can be internalized. When computing
-// function summary we also assign readonly or writeonly attribute to a
-// reference if function doesn't modify referenced variable (readonly)
-// or doesn't read it (writeonly).
-//
-// - After computing dead symbols in combined index we do the attribute
-// propagation. During this step we:
-// a. clear RO and WO attributes from variables which are preserved or
-// can't be imported
-// b. clear RO and WO attributes from variables referenced by any global
-// variable initializer
-// c. clear RO attribute from variable referenced by a function when
-// reference is not readonly
-// d. clear WO attribute from variable referenced by a function when
-// reference is not writeonly
+// Do the constant propagation in combined index.
+// The goal of constant propagation is internalization of readonly
+// variables. To determine which variables are readonly and which
+// are not we take following steps:
+// - During analysis we speculatively assign readonly attribute to
+// all variables which can be internalized. When computing function
+// summary we also assign readonly attribute to a reference if
+// function doesn't modify referenced variable.
//
-// Because of (c, d) we don't internalize variables read by function A
-// and modified by function B.
+// - After computing dead symbols in combined index we do the constant
+// propagation. During this step we clear readonly attribute from
+// all variables which:
+// a. are preserved or can't be imported
+// b. referenced by any global variable initializer
+// c. referenced by a function and reference is not readonly
//
// Internalization itself happens in the backend after import is finished
-// See internalizeGVsAfterImport.
-void ModuleSummaryIndex::propagateAttributes(
+// See internalizeImmutableGVs.
+void ModuleSummaryIndex::propagateConstants(
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
for (auto &P : *this)
for (auto &S : P.second.SummaryList) {
@@ -161,36 +148,29 @@ void ModuleSummaryIndex::propagateAttrib
// We don't examine references from dead objects
continue;
- // Global variable can't be marked read/writeonly if it is not eligible
- // to import since we need to ensure that all external references get
- // a local (imported) copy. It also can't be marked read/writeonly if
- // it or any alias (since alias points to the same memory) are preserved
- // or notEligibleToImport, since either of those means there could be
- // writes (or reads in case of writeonly) that are not visible (because
- // preserved means it could have external to DSO writes or reads, and
- // notEligibleToImport means it could have writes or reads via inline
- // assembly leading it to be in the @llvm.*used).
+ // Global variable can't be marked read only if it is not eligible
+ // to import since we need to ensure that all external references
+ // get a local (imported) copy. It also can't be marked read only
+ // if it or any alias (since alias points to the same memory) are
+ // preserved or notEligibleToImport, since either of those means
+ // there could be writes that are not visible (because preserved
+ // means it could have external to DSO writes, and notEligibleToImport
+ // means it could have writes via inline assembly leading it to be
+ // in the @llvm.*used).
if (auto *GVS = dyn_cast<GlobalVarSummary>(S->getBaseObject()))
// Here we intentionally pass S.get() not GVS, because S could be
// an alias.
- if (!canImportGlobalVar(S.get()) ||
- GUIDPreservedSymbols.count(P.first)) {
+ if (!canImportGlobalVar(S.get()) || GUIDPreservedSymbols.count(P.first))
GVS->setReadOnly(false);
- GVS->setWriteOnly(false);
- }
- propagateAttributesToRefs(S.get());
+ propagateConstantsToRefs(S.get());
}
if (llvm::AreStatisticsEnabled())
for (auto &P : *this)
if (P.second.SummaryList.size())
if (auto *GVS = dyn_cast<GlobalVarSummary>(
P.second.SummaryList[0]->getBaseObject()))
- if (isGlobalValueLive(GVS)) {
- if (GVS->maybeReadOnly())
- ReadOnlyLiveGVars++;
- if (GVS->maybeWriteOnly())
- WriteOnlyLiveGVars++;
- }
+ if (isGlobalValueLive(GVS) && GVS->isReadOnly())
+ ReadOnlyLiveGVars++;
}
// TODO: write a graphviz dumper for SCCs (see ModuleSummaryIndex::exportToDot)
@@ -353,13 +333,7 @@ static void defineExternalNode(raw_ostre
static bool hasReadOnlyFlag(const GlobalValueSummary *S) {
if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
- return GVS->maybeReadOnly();
- return false;
-}
-
-static bool hasWriteOnlyFlag(const GlobalValueSummary *S) {
- if (auto *GVS = dyn_cast<GlobalVarSummary>(S))
- return GVS->maybeWriteOnly();
+ return GVS->isReadOnly();
return false;
}
@@ -384,14 +358,12 @@ void ModuleSummaryIndex::exportToDot(raw
// 0 - alias
// 1 - reference
// 2 - constant reference
- // 3 - writeonly reference
- // Other value: (hotness - 4).
- TypeOrHotness += 4;
+ // Other value: (hotness - 3).
+ TypeOrHotness += 3;
static const char *EdgeAttrs[] = {
" [style=dotted]; // alias",
" [style=dashed]; // ref",
" [style=dashed,color=forestgreen]; // const-ref",
- " [style=dashed,color=violetred]; // writeOnly-ref",
" // call (hotness : Unknown)",
" [color=blue]; // call (hotness : Cold)",
" // call (hotness : None)",
@@ -436,8 +408,6 @@ void ModuleSummaryIndex::exportToDot(raw
A.add("shape", "Mrecord", "variable");
if (Flags.Live && hasReadOnlyFlag(SummaryIt.second))
A.addComment("immutable");
- if (Flags.Live && hasWriteOnlyFlag(SummaryIt.second))
- A.addComment("writeOnly");
}
if (Flags.DSOLocal)
A.addComment("dsoLocal");
@@ -459,11 +429,10 @@ void ModuleSummaryIndex::exportToDot(raw
for (auto &SummaryIt : GVSMap) {
auto *GVS = SummaryIt.second;
for (auto &R : GVS->refs())
- Draw(SummaryIt.first, R.getGUID(),
- R.isWriteOnly() ? -1 : (R.isReadOnly() ? -2 : -3));
+ Draw(SummaryIt.first, R.getGUID(), R.isReadOnly() ? -1 : -2);
if (auto *AS = dyn_cast_or_null<AliasSummary>(SummaryIt.second)) {
- Draw(SummaryIt.first, AS->getAliaseeGUID(), -4);
+ Draw(SummaryIt.first, AS->getAliaseeGUID(), -3);
continue;
}
Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Wed Jul 3 17:03:30 2019
@@ -192,10 +192,8 @@ void llvm::computeLTOCacheKey(
AddUnsigned(VI.isDSOLocal());
AddUsedCfiGlobal(VI.getGUID());
}
- if (auto *GVS = dyn_cast<GlobalVarSummary>(GS)) {
- AddUnsigned(GVS->maybeReadOnly());
- AddUnsigned(GVS->maybeWriteOnly());
- }
+ if (auto *GVS = dyn_cast<GlobalVarSummary>(GS))
+ AddUnsigned(GVS->isReadOnly());
if (auto *FS = dyn_cast<FunctionSummary>(GS)) {
for (auto &TT : FS->type_tests())
UsedTypeIds.insert(TT);
@@ -373,9 +371,9 @@ void llvm::thinLTOResolvePrevailingInInd
GUIDPreservedSymbols);
}
-static bool isWeakObjectWithRWAccess(GlobalValueSummary *GVS) {
+static bool isWeakWriteableObject(GlobalValueSummary *GVS) {
if (auto *VarSummary = dyn_cast<GlobalVarSummary>(GVS->getBaseObject()))
- return !VarSummary->maybeReadOnly() && !VarSummary->maybeWriteOnly() &&
+ return !VarSummary->isReadOnly() &&
(VarSummary->linkage() == GlobalValue::WeakODRLinkage ||
VarSummary->linkage() == GlobalValue::LinkOnceODRLinkage);
return false;
@@ -396,12 +394,11 @@ static void thinLTOInternalizeAndPromote
// We can't internalize available_externally globals because this
// can break function pointer equality.
S->linkage() != GlobalValue::AvailableExternallyLinkage &&
- // Functions and read-only variables with linkonce_odr and
- // weak_odr linkage can be internalized. We can't internalize
- // linkonce_odr and weak_odr variables which are both modified
- // and read somewhere in the program because reads and writes
- // will become inconsistent.
- !isWeakObjectWithRWAccess(S.get()))
+ // Functions and read-only variables with linkonce_odr and weak_odr
+ // linkage can be internalized. We can't internalize linkonce_odr
+ // and weak_odr variables which are modified somewhere in the
+ // program because reads and writes will become inconsistent.
+ !isWeakWriteableObject(S.get()))
S->setLinkage(GlobalValue::InternalLinkage);
}
}
Modified: llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp Wed Jul 3 17:03:30 2019
@@ -850,16 +850,14 @@ void llvm::computeDeadSymbolsWithConstPr
bool ImportEnabled) {
computeDeadSymbols(Index, GUIDPreservedSymbols, isPrevailing);
if (ImportEnabled) {
- Index.propagateAttributes(GUIDPreservedSymbols);
+ Index.propagateConstants(GUIDPreservedSymbols);
} else {
- // If import is disabled we should drop read/write-only attribute
+ // If import is disabled we should drop read-only attribute
// from all summaries to prevent internalization.
for (auto &P : Index)
for (auto &S : P.second.SummaryList)
- if (auto *GVS = dyn_cast<GlobalVarSummary>(S.get())) {
+ if (auto *GVS = dyn_cast<GlobalVarSummary>(S.get()))
GVS->setReadOnly(false);
- GVS->setWriteOnly(false);
- }
}
}
@@ -1066,7 +1064,7 @@ static Function *replaceAliasWithAliasee
// Internalize values that we marked with specific attribute
// in processGlobalForThinLTO.
-static void internalizeGVsAfterImport(Module &M) {
+static void internalizeImmutableGVs(Module &M) {
for (auto &GV : M.globals())
// Skip GVs which have been converted to declarations
// by dropDeadSymbols.
@@ -1199,7 +1197,7 @@ Expected<bool> FunctionImporter::importF
NumImportedModules++;
}
- internalizeGVsAfterImport(DestModule);
+ internalizeImmutableGVs(DestModule);
NumImportedFunctions += (ImportedCount - ImportedGVCount);
NumImportedGlobalVars += ImportedGVCount;
Modified: llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp Wed Jul 3 17:03:30 2019
@@ -229,11 +229,11 @@ void FunctionImportGlobalProcessing::pro
}
}
- // Mark read/write-only variables which can be imported with specific
- // attribute. We can't internalize them now because IRMover will fail
- // to link variable definitions to their external declarations during
- // ThinLTO import. We'll internalize read-only variables later, after
- // import is finished. See internalizeGVsAfterImport.
+ // Mark read-only variables which can be imported with specific attribute.
+ // We can't internalize them now because IRMover will fail to link variable
+ // definitions to their external declarations during ThinLTO import. We'll
+ // internalize read-only variables later, after import is finished.
+ // See internalizeImmutableGVs.
//
// If global value dead stripping is not enabled in summary then
// propagateConstants hasn't been run. We can't internalize GV
@@ -241,8 +241,7 @@ void FunctionImportGlobalProcessing::pro
if (!GV.isDeclaration() && VI && ImportIndex.withGlobalValueDeadStripping()) {
const auto &SL = VI.getSummaryList();
auto *GVS = SL.empty() ? nullptr : dyn_cast<GlobalVarSummary>(SL[0].get());
- // At this stage "maybe" is "definitely"
- if (GVS && (GVS->maybeReadOnly() || GVS->maybeWriteOnly()))
+ if (GVS && GVS->isReadOnly())
cast<GlobalVariable>(&GV)->addAttribute("thinlto-internalize");
}
Modified: llvm/trunk/test/Assembler/thinlto-summary.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/thinlto-summary.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/thinlto-summary.ll (original)
+++ llvm/trunk/test/Assembler/thinlto-summary.ll Wed Jul 3 17:03:30 2019
@@ -9,7 +9,7 @@
; Check a function that makes several calls with various profile hotness, and a
; reference (also tests forward references to function and variables in calls
; and refs).
-^2 = gv: (guid: 1, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 10, calls: ((callee: ^15, hotness: hot), (callee: ^17, hotness: cold), (callee: ^16, hotness: none)), refs: (writeonly ^14, readonly ^13, ^11))))
+^2 = gv: (guid: 1, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 10, calls: ((callee: ^15, hotness: hot), (callee: ^17, hotness: cold), (callee: ^16, hotness: none)), refs: (readonly ^13, ^14))))
; Function with a call that has relative block frequency instead of profile
; hotness.
@@ -33,7 +33,7 @@
^13 = gv: (guid: 12, summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), varFlags: (readonly: 1))))
; Test a dsoLocal variable.
-^14 = gv: (guid: 13, summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 1), varFlags: (writeonly: 0))))
+^14 = gv: (guid: 13, summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 1), varFlags: (readonly: 0))))
; Functions with various flag combinations (notEligibleToImport, Live,
; combinations of optional function flags).
@@ -67,7 +67,7 @@
; Make sure we get back from llvm-dis essentially what we put in via llvm-as.
; CHECK: ^0 = module: (path: "thinlto-summary1.o", hash: (1369602428, 2747878711, 259090915, 2507395659, 1141468049))
; CHECK: ^1 = module: (path: "thinlto-summary2.o", hash: (2998369023, 4283347029, 1195487472, 2757298015, 1852134156))
-; CHECK: ^2 = gv: (guid: 1, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 10, calls: ((callee: ^15, hotness: hot), (callee: ^17, hotness: cold), (callee: ^16, hotness: none)), refs: (^11, readonly ^13, writeonly ^14))))
+; CHECK: ^2 = gv: (guid: 1, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 10, calls: ((callee: ^15, hotness: hot), (callee: ^17, hotness: cold), (callee: ^16, hotness: none)), refs: (^14, readonly ^13))))
; CHECK: ^3 = gv: (guid: 2, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 10, calls: ((callee: ^15)))))
; CHECK: ^4 = gv: (guid: 3, summaries: (function: (module: ^0, flags: (linkage: internal, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 1)))
; CHECK: ^5 = gv: (guid: 4, summaries: (alias: (module: ^0, flags: (linkage: private, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), aliasee: ^14)))
@@ -76,10 +76,10 @@
; CHECK: ^8 = gv: (guid: 7, summaries: (function: (module: ^0, flags: (linkage: linkonce_odr, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))
; CHECK: ^9 = gv: (guid: 8, summaries: (function: (module: ^0, flags: (linkage: weak_odr, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 1), insts: 1)))
; CHECK: ^10 = gv: (guid: 9, summaries: (function: (module: ^0, flags: (linkage: weak, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))
-; CHECK: ^11 = gv: (guid: 10, summaries: (variable: (module: ^0, flags: (linkage: common, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0))))
-; CHECK: ^12 = gv: (guid: 11, summaries: (variable: (module: ^0, flags: (linkage: appending, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), refs: (^4))))
-; CHECK: ^13 = gv: (guid: 12, summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 1, writeonly: 0))))
-; CHECK: ^14 = gv: (guid: 13, summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0))))
+; CHECK: ^11 = gv: (guid: 10, summaries: (variable: (module: ^0, flags: (linkage: common, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0))))
+; CHECK: ^12 = gv: (guid: 11, summaries: (variable: (module: ^0, flags: (linkage: appending, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0), refs: (^4))))
+; CHECK: ^13 = gv: (guid: 12, summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 1))))
+; CHECK: ^14 = gv: (guid: 13, summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), varFlags: (readonly: 0))))
; CHECK: ^15 = gv: (guid: 14, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 1, live: 1, dsoLocal: 0, canAutoHide: 0), insts: 1)))
; CHECK: ^16 = gv: (guid: 15, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1, funcFlags: (readNone: 1, readOnly: 0, noRecurse: 1, returnDoesNotAlias: 0, noInline: 0))))
; CHECK: ^17 = gv: (guid: 16, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 1, noRecurse: 0, returnDoesNotAlias: 1, noInline: 0), calls: ((callee: ^15)))))
Modified: llvm/trunk/test/Assembler/thinlto-vtable-summary.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/thinlto-vtable-summary.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/thinlto-vtable-summary.ll (original)
+++ llvm/trunk/test/Assembler/thinlto-vtable-summary.ll Wed Jul 3 17:03:30 2019
@@ -29,9 +29,9 @@ declare i32 @_ZN1C1fEi(%struct.C*, i32)
^0 = module: (path: "<stdin>", hash: (0, 0, 0, 0, 0))
^1 = gv: (name: "_ZN1A1nEi") ; guid = 1621563287929432257
-^2 = gv: (name: "_ZTV1B", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), vTableFuncs: ((virtFunc: ^3, offset: 16), (virtFunc: ^1, offset: 24)), refs: (^3, ^1)))) ; guid = 5283576821522790367
+^2 = gv: (name: "_ZTV1B", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0), vTableFuncs: ((virtFunc: ^3, offset: 16), (virtFunc: ^1, offset: 24)), refs: (^3, ^1)))) ; guid = 5283576821522790367
^3 = gv: (name: "_ZN1B1fEi") ; guid = 7162046368816414394
-^4 = gv: (name: "_ZTV1C", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), vTableFuncs: ((virtFunc: ^5, offset: 16), (virtFunc: ^1, offset: 24)), refs: (^1, ^5)))) ; guid = 13624023785555846296
+^4 = gv: (name: "_ZTV1C", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0), vTableFuncs: ((virtFunc: ^5, offset: 16), (virtFunc: ^1, offset: 24)), refs: (^1, ^5)))) ; guid = 13624023785555846296
^5 = gv: (name: "_ZN1C1fEi") ; guid = 14876272565662207556
^6 = typeidCompatibleVTable: (name: "_ZTS1A", summary: ((offset: 16, ^2), (offset: 16, ^4))) ; guid = 7004155349499253778
^7 = typeidCompatibleVTable: (name: "_ZTS1B", summary: ((offset: 16, ^2))) ; guid = 6203814149063363976
Modified: llvm/trunk/test/Bitcode/summary_version.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/summary_version.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/summary_version.ll (original)
+++ llvm/trunk/test/Bitcode/summary_version.ll Wed Jul 3 17:03:30 2019
@@ -2,7 +2,7 @@
; RUN: opt -module-summary %s -o - | llvm-bcanalyzer -dump | FileCheck %s
; CHECK: <GLOBALVAL_SUMMARY_BLOCK
-; CHECK: <VERSION op0=7/>
+; CHECK: <VERSION op0=6/>
Modified: llvm/trunk/test/Bitcode/thinlto-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-alias.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-alias.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-alias.ll Wed Jul 3 17:03:30 2019
@@ -21,7 +21,7 @@
; CHECK-NEXT: <FLAGS
; See if the call to func is registered.
; The value id 1 matches the second FUNCTION record above.
-; CHECK-NEXT: <PERMODULE {{.*}} op7=1/>
+; CHECK-NEXT: <PERMODULE {{.*}} op6=1/>
; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
; CHECK: <STRTAB_BLOCK
@@ -34,7 +34,7 @@
; COMBINED-NEXT: <VALUE_GUID op0=[[ALIASID:[0-9]+]] op1=-5751648690987223394/>
; COMBINED-NEXT: <VALUE_GUID
; COMBINED-NEXT: <VALUE_GUID op0=[[ALIASEEID:[0-9]+]] op1=-1039159065113703048/>
-; COMBINED-NEXT: <COMBINED {{.*}} op9=[[ALIASID]]/>
+; COMBINED-NEXT: <COMBINED {{.*}} op8=[[ALIASID]]/>
; COMBINED-NEXT: <COMBINED {{.*}}
; COMBINED-NEXT: <COMBINED_ALIAS {{.*}} op3=[[ALIASEEID]]
; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK
Modified: llvm/trunk/test/Bitcode/thinlto-alias2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-alias2.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-alias2.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-alias2.ll Wed Jul 3 17:03:30 2019
@@ -5,7 +5,7 @@
; CHECK: <GLOBALVAL_SUMMARY_BLOCK
; CHECK-NEXT: <VERSION
; CHECK-NEXT: <FLAGS
-; CHECK-NEXT: <PERMODULE {{.*}} op4=0 op5=0 op6=0 op7=[[ALIASID:[0-9]+]]/>
+; CHECK-NEXT: <PERMODULE {{.*}} op4=0 op5=0 op6=[[ALIASID:[0-9]+]]/>
; CHECK-NEXT: <PERMODULE {{.*}} op0=[[ALIASEEID:[0-9]+]]
; CHECK-NEXT: <ALIAS {{.*}} op0=[[ALIASID]] {{.*}} op2=[[ALIASEEID]]/>
; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-cast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-cast.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-cast.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-cast.ll Wed Jul 3 17:03:30 2019
@@ -7,9 +7,9 @@
; CHECK-NEXT: <VERSION
; CHECK-NEXT: <FLAGS
; "op7" is a call to "callee" function.
-; CHECK-NEXT: <PERMODULE {{.*}} op9=3 op10=[[ALIASID:[0-9]+]]/>
+; CHECK-NEXT: <PERMODULE {{.*}} op8=3 op9=[[ALIASID:[0-9]+]]/>
; "another_caller" has only references but no calls.
-; CHECK-NEXT: <PERMODULE {{.*}} op4=3 {{.*}} op9={{[0-9]+}}/>
+; CHECK-NEXT: <PERMODULE {{.*}} op4=3 {{.*}} op8={{[0-9]+}}/>
; CHECK-NEXT: <PERMODULE {{.*}} op0=[[ALIASEEID:[0-9]+]]
; CHECK-NEXT: <ALIAS {{.*}} op0=[[ALIASID]] {{.*}} op2=[[ALIASEEID]]/>
; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll Wed Jul 3 17:03:30 2019
@@ -18,7 +18,7 @@
; CHECK-NEXT: <VERSION
; CHECK-NEXT: <FLAGS
; See if the call to func is registered, using the expected hotness type.
-; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op7=1 op8=2/>
+; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op6=1 op7=2/>
; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
; CHECK: <STRTAB_BLOCK
; CHECK-NEXT: blob data = 'mainfunc{{.*}}'
@@ -31,7 +31,7 @@
; COMBINED-NEXT: <COMBINED
; See if the call to func is registered, using the expected hotness type.
; op6=2 which is hotnessType::None.
-; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op9=[[FUNCID]] op10=2/>
+; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op8=[[FUNCID]] op9=2/>
; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
; ModuleID = 'thinlto-function-summary-callgraph.ll'
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll Wed Jul 3 17:03:30 2019
@@ -49,7 +49,7 @@
; CHECK-NEXT: <FLAGS
; CHECK-NEXT: <VALUE_GUID op0=25 op1=123/>
; op4=hot1 op6=cold op8=hot2 op10=hot4 op12=none1 op14=hot3 op16=none2 op18=none3 op20=123
-; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op7=1 op8=3 op9=5 op10=1 op11=2 op12=3 op13=4 op14=1 op15=6 op16=2 op17=3 op18=3 op19=7 op20=2 op21=8 op22=2 op23=25 op24=4/>
+; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op6=1 op7=3 op8=5 op9=1 op10=2 op11=3 op12=4 op13=1 op14=6 op15=2 op16=3 op17=3 op18=7 op19=2 op20=8 op21=2 op22=25 op23=4/>
; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
; CHECK: <STRTAB_BLOCK
@@ -72,7 +72,7 @@
; COMBINED-NEXT: <COMBINED abbrevid=
; COMBINED-NEXT: <COMBINED abbrevid=
; COMBINED-NEXT: <COMBINED abbrevid=
-; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op9=[[HOT1:.*]] op10=3 op11=[[COLD:.*]] op12=1 op13=[[HOT2:.*]] op14=3 op15=[[NONE1:.*]] op16=2 op17=[[HOT3:.*]] op18=3 op19=[[NONE2:.*]] op20=2 op21=[[NONE3:.*]] op22=2/>
+; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op8=[[HOT1:.*]] op9=3 op10=[[COLD:.*]] op11=1 op12=[[HOT2:.*]] op13=3 op14=[[NONE1:.*]] op15=2 op16=[[HOT3:.*]] op17=3 op18=[[NONE2:.*]] op19=2 op20=[[NONE3:.*]] op21=2/>
; COMBINED_NEXT: <COMBINED abbrevid=
; COMBINED_NEXT: </GLOBALVAL_SUMMARY_BLOCK>
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-relbf.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-relbf.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-relbf.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-relbf.ll Wed Jul 3 17:03:30 2019
@@ -14,7 +14,7 @@
; CHECK-NEXT: <VERSION
; CHECK-NEXT: <FLAGS
; See if the call to func is registered.
-; CHECK-NEXT: <PERMODULE_RELBF {{.*}} op4=1 {{.*}} op9=256
+; CHECK-NEXT: <PERMODULE_RELBF {{.*}} op4=1 {{.*}} op8=256
; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
; CHECK: <STRTAB_BLOCK
; CHECK-NEXT: blob data = 'undefinedglobmainfunc{{.*}}'
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll Wed Jul 3 17:03:30 2019
@@ -32,7 +32,7 @@
; CHECK-NEXT: <FLAGS
; CHECK-NEXT: <VALUE_GUID op0=26 op1=123/>
; op4=none1 op6=hot1 op8=cold1 op10=none2 op12=hot2 op14=cold2 op16=none3 op18=hot3 op20=cold3 op22=123
-; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op7=7 op8=0 op9=1 op10=3 op11=4 op12=1 op13=8 op14=0 op15=2 op16=3 op17=5 op18=1 op19=9 op20=0 op21=3 op22=3 op23=6 op24=1 op25=26 op26=4/>
+; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op6=7 op7=0 op8=1 op9=3 op10=4 op11=1 op12=8 op13=0 op14=2 op15=3 op16=5 op17=1 op18=9 op19=0 op20=3 op21=3 op22=6 op23=1 op24=26 op25=4/>
; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
; CHECK: <STRTAB_BLOCK
@@ -59,7 +59,7 @@
; COMBINED-NEXT: <COMBINED abbrevid=
; COMBINED-NEXT: <COMBINED abbrevid=
; COMBINED-NEXT: <COMBINED abbrevid=
-; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op9=[[NONE1:.*]] op10=0 op11=[[HOT1:.*]] op12=3 op13=[[COLD1:.*]] op14=1 op15=[[NONE2:.*]] op16=0 op17=[[HOT2:.*]] op18=3 op19=[[COLD2:.*]] op20=1 op21=[[NONE3:.*]] op22=0 op23=[[HOT3:.*]] op24=3 op25=[[COLD3:.*]] op26=1/>
+; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op8=[[NONE1:.*]] op9=0 op10=[[HOT1:.*]] op11=3 op12=[[COLD1:.*]] op13=1 op14=[[NONE2:.*]] op15=0 op16=[[HOT2:.*]] op17=3 op18=[[COLD2:.*]] op19=1 op20=[[NONE3:.*]] op21=0 op22=[[HOT3:.*]] op23=3 op24=[[COLD3:.*]] op25=1/>
; COMBINED_NEXT: <COMBINED abbrevid=
; COMBINED_NEXT: </GLOBALVAL_SUMMARY_BLOCK>
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-callgraph.ll Wed Jul 3 17:03:30 2019
@@ -34,7 +34,7 @@
; COMBINED-NEXT: <VALUE_GUID
; COMBINED-NEXT: <COMBINED
; See if the call to func is registered.
-; COMBINED-NEXT: <COMBINED {{.*}} op9=[[FUNCID]]/>
+; COMBINED-NEXT: <COMBINED {{.*}} op8=[[FUNCID]]/>
; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
; ModuleID = 'thinlto-function-summary-callgraph.ll'
Modified: llvm/trunk/test/Bitcode/thinlto-function-summary-refgraph.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/thinlto-function-summary-refgraph.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/thinlto-function-summary-refgraph.ll (original)
+++ llvm/trunk/test/Bitcode/thinlto-function-summary-refgraph.ll Wed Jul 3 17:03:30 2019
@@ -41,27 +41,27 @@
; CHECK: <GLOBALVAL_SUMMARY_BLOCK
; Function main contains call to func, as well as address reference to func:
; op0=main op4=func op5=func
-; CHECK-DAG: <PERMODULE {{.*}} op0=11 op1=0 {{.*}} op4=1 op5=0 op6=0 op7=2 op8=2/>
+; CHECK-DAG: <PERMODULE {{.*}} op0=11 op1=0 {{.*}} op4=1 op5=0 op6=2 op7=2/>
; Function W contains a call to func3 as well as a reference to globalvar:
; op0=W op4=globalvar op5=func3
-; CHECK-DAG: <PERMODULE {{.*}} op0=6 op1=5 {{.*}} op4=1 op5=0 op6=0 op7=1 op8=5/>
+; CHECK-DAG: <PERMODULE {{.*}} op0=6 op1=5 {{.*}} op4=1 op5=0 op6=1 op7=5/>
; Function X contains call to foo, as well as address reference to foo
; which is in the same instruction as the call:
; op0=X op4=foo op5=foo
-; CHECK-DAG: <PERMODULE {{.*}} op0=7 op1=1 {{.*}} op4=1 op5=0 op6=0 op7=4 op8=4/>
+; CHECK-DAG: <PERMODULE {{.*}} op0=7 op1=1 {{.*}} op4=1 op5=0 op6=4 op7=4/>
; Function Y contains call to func2, and ensures we don't incorrectly add
; a reference to it when reached while earlier analyzing the phi using its
; return value:
; op0=Y op4=func2
-; CHECK-DAG: <PERMODULE {{.*}} op0=8 op1=72 {{.*}} op4=0 op5=0 op6=0 op7=3/>
+; CHECK-DAG: <PERMODULE {{.*}} op0=8 op1=72 {{.*}} op4=0 op5=0 op6=3/>
; Function Z contains call to func2, and ensures we don't incorrectly add
; a reference to it when reached while analyzing subsequent use of its return
; value:
; op0=Z op4=func2
-; CHECK-DAG: <PERMODULE {{.*}} op0=9 op1=3 {{.*}} op4=0 op5=0 op6=0 op7=3/>
+; CHECK-DAG: <PERMODULE {{.*}} op0=9 op1=3 {{.*}} op4=0 op5=0 op6=3/>
; Variable bar initialization contains address reference to func:
; op0=bar op2=func
-; CHECK-DAG: <PERMODULE_GLOBALVAR_INIT_REFS {{.*}} op0=0 op1=0 op2=3 op3=2/>
+; CHECK-DAG: <PERMODULE_GLOBALVAR_INIT_REFS {{.*}} op0=0 op1=0 op2=1 op3=2/>
; CHECK: </GLOBALVAL_SUMMARY_BLOCK>
; CHECK: <STRTAB_BLOCK
@@ -154,11 +154,11 @@ entry:
; DIS-DAG: = gv: (name: "foo") ; guid = 6699318081062747564
; DIS-DAG: = gv: (name: "func") ; guid = 7289175272376759421
; DIS-DAG: = gv: (name: "func3") ; guid = 11517462787082255043
-; DIS-DAG: = gv: (name: "globalvar", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 1, writeonly: 1)))) ; guid = 12887606300320728018
+; DIS-DAG: = gv: (name: "globalvar", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 1)))) ; guid = 12887606300320728018
; DIS-DAG: = gv: (name: "func2") ; guid = 14069196320850861797
; DIS-DAG: = gv: (name: "llvm.ctpop.i8") ; guid = 15254915475081819833
; DIS-DAG: = gv: (name: "main", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 9, calls: ((callee: ^{{.*}})), refs: (^{{.*}})))) ; guid = 15822663052811949562
-; DIS-DAG: = gv: (name: "bar", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 1, writeonly: 1), refs: (^{{.*}})))) ; guid = 16434608426314478903
+; DIS-DAG: = gv: (name: "bar", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 1), refs: (^{{.*}})))) ; guid = 16434608426314478903
; Don't try to match the exact GUID. Since it is private, the file path
; will get hashed, and that will be test dependent.
; DIS-DAG: = gv: (name: "Y", summaries: (function: (module: ^0, flags: (linkage: private, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 14, calls: ((callee: ^{{.*}}))))) ; guid =
Removed: llvm/trunk/test/ThinLTO/X86/Inputs/dot-dumper2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/Inputs/dot-dumper2.ll?rev=365096&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/Inputs/dot-dumper2.ll (original)
+++ llvm/trunk/test/ThinLTO/X86/Inputs/dot-dumper2.ll (removed)
@@ -1,4 +0,0 @@
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
- at A = local_unnamed_addr global i32 10, align 4
Removed: llvm/trunk/test/ThinLTO/X86/dot-dumper2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/dot-dumper2.ll?rev=365096&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/dot-dumper2.ll (original)
+++ llvm/trunk/test/ThinLTO/X86/dot-dumper2.ll (removed)
@@ -1,43 +0,0 @@
-; Test writeOnly attribute
-; RUN: opt -module-summary %s -o %t1.bc
-; RUN: opt -module-summary %p/Inputs/dot-dumper2.ll -o %t2.bc
-; RUN: llvm-lto2 run -save-temps %t1.bc %t2.bc -o %t3 \
-; RUN: -r=%t1.bc,main,px \
-; RUN: -r=%t1.bc,A, \
-; RUN: -r=%t2.bc,A,p
-
-; RUN: cat %t3.index.dot | FileCheck --check-prefix=COMBINED %s
-
-; COMBINED: digraph Summary {
-; COMBINED-NEXT: // Module:
-; COMBINED-NEXT: subgraph cluster_0 {
-; COMBINED-NEXT: style = filled;
-; COMBINED-NEXT: color = lightgrey;
-; COMBINED-NEXT: label =
-; COMBINED-NEXT: node [style=filled,fillcolor=lightblue];
-; COMBINED-NEXT: M0_[[MAIN:[0-9]+]] [shape="record",label="main|extern (inst: 2, ffl: 00000)}"]; // function
-; COMBINED-NEXT: // Edges:
-; COMBINED-NEXT: }
-; COMBINED-NEXT: // Module:
-; COMBINED-NEXT: subgraph cluster_1 {
-; COMBINED-NEXT: style = filled;
-; COMBINED-NEXT: color = lightgrey;
-; COMBINED-NEXT: label =
-; COMBINED-NEXT: node [style=filled,fillcolor=lightblue];
-; COMBINED-NEXT: M1_[[A:[0-9]+]] [shape="Mrecord",label="A|extern}"]; // variable, writeOnly
-; COMBINED-NEXT: // Edges:
-; COMBINED-NEXT: }
-; COMBINED-NEXT: // Cross-module edges:
-; COMBINED-NEXT: M0_[[MAIN]] -> M1_[[A]] [style=dashed,color=violetred]; // writeOnly-ref
-; COMBINED-NEXT: }
-
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
- at A = external local_unnamed_addr global i32, align 4
-
-; Function Attrs: nounwind uwtable
-define i32 @main() local_unnamed_addr {
- store i32 42, i32* @A, align 4
- ret i32 0
-}
Modified: llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll?rev=365097&r1=365096&r2=365097&view=diff
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll (original)
+++ llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll Wed Jul 3 17:03:30 2019
@@ -11,10 +11,8 @@
; RUN: -r=%t2.bc,rand, \
; RUN: -r=%t2.bc,gBar,pl \
; RUN: -r=%t1.bc,main,plx \
-; RUN: -r=%t1.bc,main2,pl \
; RUN: -r=%t1.bc,foo, \
; RUN: -r=%t1.bc,bar, \
-; RUN: -r=%t1.bc,baz, \
; RUN: -r=%t1.bc,gBar, \
; RUN: -o %t3
; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT
@@ -28,32 +26,11 @@
; RUN: -r=%t2.bc,rand, \
; RUN: -r=%t2.bc,gBar,plx \
; RUN: -r=%t1.bc,main,plx \
-; RUN: -r=%t1.bc,main2,pl \
; RUN: -r=%t1.bc,foo, \
; RUN: -r=%t1.bc,bar, \
-; RUN: -r=%t1.bc,baz, \
; RUN: -r=%t1.bc,gBar, \
-; RUN: -o %t4
-; RUN: llvm-dis %t4.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT2
-
-; RUN: llvm-lto2 run %t1.bc %t2.bc -save-temps \
-; RUN: -r=%t2.bc,foo,pl \
-; RUN: -r=%t2.bc,bar,pl \
-; RUN: -r=%t2.bc,baz,pl \
-; RUN: -r=%t2.bc,rand, \
-; RUN: -r=%t2.bc,gBar,pl \
-; RUN: -r=%t1.bc,main,pl \
-; RUN: -r=%t1.bc,main2,plx \
-; RUN: -r=%t1.bc,foo, \
-; RUN: -r=%t1.bc,bar, \
-; RUN: -r=%t1.bc,baz, \
-; RUN: -r=%t1.bc,gBar, \
-; RUN: -o %t5
-; RUN: llvm-dis %t5.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT
-; RUN: llvm-dis %t5.1.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN2
-; Check that gFoo and gBar were eliminated from source module together
-; with corresponsing stores
-; RUN: llvm-dis %t5.2.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN2-SRC
+; RUN: -o %t3
+; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT2
; IMPORT: @gFoo.llvm.0 = internal unnamed_addr global i32 1, align 4
; IMPORT-NEXT: @gBar = internal local_unnamed_addr global i32 2, align 4
@@ -64,16 +41,6 @@
; IMPORT2: @gBar = available_externally dso_local local_unnamed_addr global i32 2, align 4
-; CODEGEN2: i32 @main2
-; CODEGEN2-NEXT: %1 = tail call i32 @rand()
-; CODEGEN2-NEXT: %2 = tail call i32 @rand()
-; CODEGEN2-NEXT: ret i32 0
-
-; CODEGEN2-SRC: void @baz()
-; CODEGEN2-SRC-NEXT: %1 = tail call i32 @rand()
-; CODEGEN2-SRC-NEXT: %2 = tail call i32 @rand()
-; CODEGEN2-SRC-NEXT: ret void
-
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@@ -87,13 +54,6 @@ define i32 @main() local_unnamed_addr {
ret i32 %add
}
-define i32 @main2() local_unnamed_addr {
- tail call void @baz()
- ret i32 0
-}
-
declare i32 @foo(...) local_unnamed_addr
declare i32 @bar(...) local_unnamed_addr
-
-declare void @baz() local_unnamed_addr
Removed: llvm/trunk/test/ThinLTO/X86/writeonly.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/writeonly.ll?rev=365096&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/writeonly.ll (original)
+++ llvm/trunk/test/ThinLTO/X86/writeonly.ll (removed)
@@ -1,41 +0,0 @@
-; Checks that we optimize writeonly variables and corresponding stores using llvm-lto
-; -stats requires asserts
-; REQUIRES: asserts
-
-; RUN: opt -module-summary %s -o %t1.bc
-; RUN: opt -module-summary %p/Inputs/index-const-prop.ll -o %t2.bc
-; RUN: llvm-lto -thinlto-action=thinlink -o %t3.index.bc %t1.bc %t2.bc
-
-; Check that we optimize write-only variables
-; RUN: llvm-lto -thinlto-action=import -exported-symbol=main %t1.bc -thinlto-index=%t3.index.bc -o %t1.imported.bc -stats 2>&1 | FileCheck %s --check-prefix=STATS
-; RUN: llvm-dis %t1.imported.bc -o - | FileCheck %s --check-prefix=IMPORT
-; RUN: llvm-lto -thinlto-action=optimize %t1.imported.bc -o - | llvm-dis - -o - | FileCheck %s --check-prefix=OPTIMIZE
-
-; IMPORT: @gFoo.llvm.0 = internal unnamed_addr global i32 1, align 4, !dbg !0
-; IMPORT-NEXT: @gBar = internal local_unnamed_addr global i32 2, align 4, !dbg !5
-; IMPORT: !DICompileUnit({{.*}})
-
-; STATS: 2 module-summary-index - Number of live global variables marked write only
-
-; Check that we've optimized out variables and corresponding stores
-; OPTIMIZE-NOT: gFoo
-; OPTIMIZE-NOT: gBar
-; OPTIMIZE: i32 @main
-; OPTIMIZE-NEXT: %1 = tail call i32 @rand()
-; OPTIMIZE-NEXT: %2 = tail call i32 @rand()
-; OPTIMIZE-NEXT: ret i32 0
-
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-linux-gnu"
-
- at gBar = external global i32
-
-; Should not be counted in the stats of live write only variables since it is
-; dead and will be dropped anyway.
- at gDead = internal unnamed_addr global i32 1, align 4
-
-define i32 @main() local_unnamed_addr {
- tail call void @baz()
- ret i32 0
-}
-declare void @baz() local_unnamed_addr
Removed: llvm/trunk/test/ThinLTO/X86/writeonly2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/writeonly2.ll?rev=365096&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/writeonly2.ll (original)
+++ llvm/trunk/test/ThinLTO/X86/writeonly2.ll (removed)
@@ -1,50 +0,0 @@
-; Check that we optimize out writeonly variables and corresponding stores.
-; This test uses llvm-lto2
-
-; RUN: opt -module-summary %s -o %t1.bc
-; RUN: opt -module-summary %p/Inputs/index-const-prop.ll -o %t2.bc
-; RUN: llvm-lto2 run %t1.bc %t2.bc -save-temps \
-; RUN: -r=%t2.bc,foo,pl \
-; RUN: -r=%t2.bc,bar,pl \
-; RUN: -r=%t2.bc,baz,pl \
-; RUN: -r=%t2.bc,rand, \
-; RUN: -r=%t2.bc,gBar,pl \
-; RUN: -r=%t1.bc,main,plx \
-; RUN: -r=%t1.bc,baz, \
-; RUN: -r=%t1.bc,gBar, \
-; RUN: -o %t3
-; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT
-; RUN: llvm-dis %t3.1.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN
-; Check that gFoo and gBar were eliminated from source module together
-; with corresponsing stores
-; RUN: llvm-dis %t3.2.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN-SRC
-
-; IMPORT: @gFoo.llvm.0 = internal unnamed_addr global i32 1, align 4
-; IMPORT-NEXT: @gBar = internal local_unnamed_addr global i32 2, align 4
-; IMPORT: !DICompileUnit({{.*}})
-
-; CODEGEN-NOT: gFoo
-; CODEGEN-NOT: gBar
-; CODEGEN: i32 @main
-; CODEGEN-NEXT: %1 = tail call i32 @rand()
-; CODEGEN-NEXT: %2 = tail call i32 @rand()
-; CODEGEN-NEXT: ret i32 0
-
-; CODEGEN-SRC-NOT: gFoo
-; CODEGEN-SRC-NOT: gBar
-; CODEGEN-SRC: void @baz()
-; CODEGEN-SRC-NEXT: %1 = tail call i32 @rand()
-; CODEGEN-SRC-NEXT: %2 = tail call i32 @rand()
-; CODEGEN-SRC-NEXT: ret void
-
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-linux-gnu"
-
-; We should be able to link external definition of gBar to its declaration
- at gBar = external global i32
-
-define i32 @main() local_unnamed_addr {
- tail call void @baz()
- ret i32 0
-}
-declare void @baz() local_unnamed_addr
More information about the llvm-commits
mailing list