summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Globals.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-05-29 03:29:01 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2019-05-29 03:29:01 +0000
commit31fda09b2db405bbaa225bb6068c5f787506b9db (patch)
treec6571ccf7d6848532f8a4e92c9027a0fc9ed047a /llvm/lib/IR/Globals.cpp
parent10c548cdfa1ebe15c0312d373191b09fbe7b6a3c (diff)
downloadbcm5719-llvm-31fda09b2db405bbaa225bb6068c5f787506b9db.tar.gz
bcm5719-llvm-31fda09b2db405bbaa225bb6068c5f787506b9db.zip
Add IR support, ELF section and user documentation for partitioning feature.
The partitioning feature was proposed here: http://lists.llvm.org/pipermail/llvm-dev/2019-February/130583.html This is mostly just documentation. The feature itself will be contributed in subsequent patches. Differential Revision: https://reviews.llvm.org/D60242 llvm-svn: 361923
Diffstat (limited to 'llvm/lib/IR/Globals.cpp')
-rw-r--r--llvm/lib/IR/Globals.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index b3fdcc6a5fc..e2bfc0420bc 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -67,6 +67,7 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
setUnnamedAddr(Src->getUnnamedAddr());
setDLLStorageClass(Src->getDLLStorageClass());
setDSOLocal(Src->isDSOLocal());
+ setPartition(Src->getPartition());
}
void GlobalValue::removeFromParent() {
@@ -180,6 +181,28 @@ const Comdat *GlobalValue::getComdat() const {
return cast<GlobalObject>(this)->getComdat();
}
+StringRef GlobalValue::getPartition() const {
+ if (!hasPartition())
+ return "";
+ return getContext().pImpl->GlobalValuePartitions[this];
+}
+
+void GlobalValue::setPartition(StringRef S) {
+ // Do nothing if we're clearing the partition and it is already empty.
+ if (!hasPartition() && S.empty())
+ return;
+
+ // Get or create a stable partition name string and put it in the table in the
+ // context.
+ if (!S.empty())
+ S = getContext().pImpl->Saver.save(S);
+ getContext().pImpl->GlobalValuePartitions[this] = S;
+
+ // Update the HasPartition field. Setting the partition to the empty string
+ // means this global no longer has a partition.
+ HasPartition = !S.empty();
+}
+
StringRef GlobalObject::getSectionImpl() const {
assert(hasSection());
return getContext().pImpl->GlobalObjectSections[this];
OpenPOWER on IntegriCloud