summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2020-01-14 06:28:37 -0800
committerTeresa Johnson <tejohnson@google.com>2020-01-14 10:54:03 -0800
commit7dc4bbf8ab311606388faacca58b6c3e3e508b77 (patch)
tree2b6390ce6d789ab5e454581a762e2c13eb1e5e22 /llvm/include
parent98c54fb1feba081c509f7e389877550df130a80d (diff)
downloadbcm5719-llvm-7dc4bbf8ab311606388faacca58b6c3e3e508b77.tar.gz
bcm5719-llvm-7dc4bbf8ab311606388faacca58b6c3e3e508b77.zip
[ThinLTO] Handle variable with twice promoted name (Rust)
Summary: Ensure that we can internalize values produced from two rounds of promotion. Note that this cannot happen currently via clang, but in other use cases such as the Rust compiler which does a first round of ThinLTO on library code, producing bitcode, and a second round on the final binary. In particular this can happen if a function is exported and promoted, ending up with a ".llvm.${hash}" suffix, and then goes through a round of optimization creating an internal switch table expansion variable that is internal and contains the promoted name of the enclosing function. This variable will be promoted in the second round of ThinLTO if @foo is imported again, and therefore ends up with two ".llvm.${hash}" suffixes. Only the final one should be stripped when consulting the index to locate the summary. Reviewers: wmi Subscribers: mehdi_amini, inglorion, hiraditya, JDevlieghere, steven_wu, dexonsmith, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72711
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/IR/ModuleSummaryIndex.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index b78c240e1d1..aa4054c8409 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1268,9 +1268,11 @@ public:
}
/// Helper to obtain the unpromoted name for a global value (or the original
- /// name if not promoted).
+ /// name if not promoted). Split off the rightmost ".llvm.${hash}" suffix,
+ /// because it is possible in certain clients (not clang at the moment) for
+ /// two rounds of ThinLTO optimization and therefore promotion to occur.
static StringRef getOriginalNameBeforePromote(StringRef Name) {
- std::pair<StringRef, StringRef> Pair = Name.split(".llvm.");
+ std::pair<StringRef, StringRef> Pair = Name.rsplit(".llvm.");
return Pair.first;
}
OpenPOWER on IntegriCloud