diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-05-24 17:24:25 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-05-24 17:24:25 +0000 |
commit | 3dce157450cd8b50403c7af07888dbb0818c5712 (patch) | |
tree | 25ee6865dd96d42a6899c9d64d359a6a7f5080c5 /include | |
parent | c6ed2a486f1f9e00cf293d19b21873537e2f7d29 (diff) |
[ThinLTO] Change ODR resolution and internalization to be index-based
Summary:
This patch changes the ODR resolution and internalization to be based on
updates to the Index, which are consumed by the backend portion of the
transformations.
It will be followed by an NFC change to move these out of libLTO's
ThinLTOCodeGenerator so that it can be used by other linkers
(gold and lld) and by ThinLTO distributed backends.
The global summary-based portions use callbacks so that the client can
determine the prevailing copy and other information in a client-specific
way. Eventually, with the API being developed in D20268, these may be
modified to use information such as symbol resolutions, supplied by the
clients to the API.
Reviewers: joker-eph
Subscribers: joker.eph, pcc, llvm-commits
Differential Revision: http://reviews.llvm.org/D20290
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270584 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/IR/ModuleSummaryIndex.h | 13 | ||||
-rw-r--r-- | include/llvm/LTO/ThinLTOCodeGenerator.h | 6 |
2 files changed, 17 insertions, 2 deletions
diff --git a/include/llvm/IR/ModuleSummaryIndex.h b/include/llvm/IR/ModuleSummaryIndex.h index a7b7560132d..6b866dbd9e9 100644 --- a/include/llvm/IR/ModuleSummaryIndex.h +++ b/include/llvm/IR/ModuleSummaryIndex.h @@ -168,6 +168,12 @@ public: return static_cast<GlobalValue::LinkageTypes>(Flags.Linkage); } + /// Sets the linkage to the value determined by global summary-based + /// optimization. Will be applied in the ThinLTO backends. + void setLinkage(GlobalValue::LinkageTypes Linkage) { + Flags.Linkage = Linkage; + } + /// Return true if this summary is for a GlobalValue that needs promotion /// to be referenced from another module. bool needsRenaming() const { return GlobalValue::isLocalLinkage(linkage()); } @@ -446,6 +452,13 @@ public: return NewName.str(); } + /// Helper to obtain the unpromoted name for a global value (or the original + /// name if not promoted). + static StringRef getOriginalNameBeforePromote(StringRef Name) { + std::pair<StringRef, StringRef> Pair = Name.split(".llvm."); + return Pair.first; + } + /// Add a new module path with the given \p Hash, mapped to the given \p /// ModID, and return an iterator to the entry in the index. ModulePathStringTableTy::iterator diff --git a/include/llvm/LTO/ThinLTOCodeGenerator.h b/include/llvm/LTO/ThinLTOCodeGenerator.h index 772122c655e..539880e8d3a 100644 --- a/include/llvm/LTO/ThinLTOCodeGenerator.h +++ b/include/llvm/LTO/ThinLTOCodeGenerator.h @@ -198,7 +198,9 @@ public: std::unique_ptr<ModuleSummaryIndex> linkCombinedIndex(); /** - * Perform promotion and renaming of exported internal functions. + * Perform promotion and renaming of exported internal functions, + * and additionally resolve weak and linkonce symbols. + * Index is updated to reflect linkage changes from weak resolution. */ void promote(Module &Module, ModuleSummaryIndex &Index); @@ -222,7 +224,7 @@ public: std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex); /** - * Perform internalization. + * Perform internalization. Index is updated to reflect linkage changes. */ void internalize(Module &Module, ModuleSummaryIndex &Index); |