[PATCH] D42528: [LTO] - Introduce GlobalResolution::Prevailing flag.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 25 04:29:08 PST 2018
grimar created this revision.
grimar added reviewers: rafael, tejohnson.
Herald added subscribers: inglorion, mehdi_amini.
It is near-NFC refactoring change that can help make https://reviews.llvm.org/D42107 a bit smaller.
(though not sure if we want to land it separatelly or not)
https://reviews.llvm.org/D42528
Files:
include/llvm/LTO/LTO.h
lib/LTO/LTO.cpp
Index: lib/LTO/LTO.cpp
===================================================================
--- lib/LTO/LTO.cpp
+++ lib/LTO/LTO.cpp
@@ -419,11 +419,14 @@
auto &GlobalRes = GlobalResolutions[Sym.getName()];
GlobalRes.UnnamedAddr &= Sym.isUnnamedAddr();
if (Res.Prevailing) {
- assert(GlobalRes.IRName.empty() &&
+ assert(!GlobalRes.Prevailing &&
"Multiple prevailing defs are not allowed");
- GlobalRes.IRName = Sym.getIRName();
+ GlobalRes.Prevailing = true;
}
+ if (GlobalRes.IRName.empty())
+ GlobalRes.IRName = Sym.getIRName();
+
// Set the partition to external if we know it is re-defined by the linker
// with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
// regular object, is referenced from llvm.compiler_used, or was already
@@ -746,14 +749,10 @@
Error LTO::run(AddStreamFn AddStream, NativeObjectCache Cache) {
// Compute "dead" symbols, we don't want to import/export these!
DenseSet<GlobalValue::GUID> GUIDPreservedSymbols;
- for (auto &Res : GlobalResolutions) {
- if (Res.second.VisibleOutsideSummary &&
- // IRName will be defined if we have seen the prevailing copy of
- // this value. If not, no need to preserve any ThinLTO copies.
- !Res.second.IRName.empty())
+ for (auto &Res : GlobalResolutions)
+ if (Res.second.VisibleOutsideSummary && Res.second.Prevailing)
GUIDPreservedSymbols.insert(GlobalValue::getGUID(
GlobalValue::dropLLVMManglingEscape(Res.second.IRName)));
- }
computeDeadSymbols(ThinLTO.CombinedIndex, GUIDPreservedSymbols);
@@ -803,7 +802,7 @@
if (!Conf.CodeGenOnly) {
for (const auto &R : GlobalResolutions) {
- if (R.second.IRName.empty())
+ if (!R.second.Prevailing)
continue;
if (R.second.Partition != 0 &&
R.second.Partition != GlobalResolution::External)
@@ -1114,13 +1113,10 @@
// undefined references during the final link.
std::set<GlobalValue::GUID> ExportedGUIDs;
for (auto &Res : GlobalResolutions) {
- // First check if the symbol was flagged as having external references.
- if (Res.second.Partition != GlobalResolution::External)
- continue;
- // IRName will be defined if we have seen the prevailing copy of
- // this value. If not, no need to mark as exported from a ThinLTO
- // partition (and we can't get the GUID).
- if (Res.second.IRName.empty())
+ // If the symbol does not have external references or it is not prevailing,
+ // then not need to mark it as exported from a ThinLTO partition.
+ if (Res.second.Partition != GlobalResolution::External ||
+ !Res.second.Prevailing)
continue;
auto GUID = GlobalValue::getGUID(
GlobalValue::dropLLVMManglingEscape(Res.second.IRName));
Index: include/llvm/LTO/LTO.h
===================================================================
--- include/llvm/LTO/LTO.h
+++ include/llvm/LTO/LTO.h
@@ -320,6 +320,8 @@
bool UnnamedAddr = true;
+ bool Prevailing = false;
+
/// This field keeps track of the partition number of this global. The
/// regular LTO object is partition 0, while each ThinLTO object has its own
/// partition number from 1 onwards.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42528.131413.patch
Type: text/x-patch
Size: 3253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180125/b2a17e90/attachment.bin>
More information about the llvm-commits
mailing list