aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/IR/Globals.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-14 22:12:13 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-14 22:12:13 +0000
commitf1a29dd3442304e183b0491fbe2d33f6c963069e (patch)
tree64b5defb92948be8b09a6f1b5c48ec60abad1325 /contrib/llvm/lib/IR/Globals.cpp
parent8a6fe8ce60ab99778558c4951d23615a0141daf0 (diff)
parent581a6d8501ff5614297da837b81ed3b6956361ea (diff)
downloadsrc-f1a29dd3442304e183b0491fbe2d33f6c963069e.tar.gz
src-f1a29dd3442304e183b0491fbe2d33f6c963069e.zip
Merge llvm, clang, lld and lldb release_40 branch r292009. Also update
build glue.
Notes
Notes: svn path=/projects/clang400-import/; revision=312197
Diffstat (limited to 'contrib/llvm/lib/IR/Globals.cpp')
-rw-r--r--contrib/llvm/lib/IR/Globals.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/contrib/llvm/lib/IR/Globals.cpp b/contrib/llvm/lib/IR/Globals.cpp
index 31f89514151c..6f7356524d38 100644
--- a/contrib/llvm/lib/IR/Globals.cpp
+++ b/contrib/llvm/lib/IR/Globals.cpp
@@ -24,6 +24,7 @@
#include "llvm/IR/Operator.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
+#include "LLVMContextImpl.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
@@ -37,6 +38,10 @@ static_assert(sizeof(GlobalValue) ==
sizeof(Constant) + 2 * sizeof(void *) + 2 * sizeof(unsigned),
"unexpected GlobalValue size growth");
+// GlobalObject adds a comdat.
+static_assert(sizeof(GlobalObject) == sizeof(GlobalValue) + sizeof(void *),
+ "unexpected GlobalObject size growth");
+
bool GlobalValue::isMaterializable() const {
if (const Function *F = dyn_cast<Function>(this))
return F->isMaterializable();
@@ -160,11 +165,24 @@ Comdat *GlobalValue::getComdat() {
return cast<GlobalObject>(this)->getComdat();
}
-void GlobalObject::setSection(StringRef S) {
- Section = S;
+StringRef GlobalObject::getSectionImpl() const {
+ assert(hasSection());
+ return getContext().pImpl->GlobalObjectSections[this];
+}
- // The C api requires this to be null terminated.
- Section.c_str();
+void GlobalObject::setSection(StringRef S) {
+ // Do nothing if we're clearing the section and it is already empty.
+ if (!hasSection() && S.empty())
+ return;
+
+ // Get or create a stable section name string and put it in the table in the
+ // context.
+ S = getContext().pImpl->SectionStrings.insert(S).first->first();
+ getContext().pImpl->GlobalObjectSections[this] = S;
+
+ // Update the HasSectionHashEntryBit. Setting the section to the empty string
+ // means this global no longer has a section.
+ setGlobalObjectFlag(HasSectionHashEntryBit, !S.empty());
}
bool GlobalValue::isDeclaration() const {