summaryrefslogtreecommitdiff
path: root/lib/IR/Globals.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/Globals.cpp')
-rw-r--r--lib/IR/Globals.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp
index 5410cc031d..244e3e4bae 100644
--- a/lib/IR/Globals.cpp
+++ b/lib/IR/Globals.cpp
@@ -59,15 +59,10 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
setDLLStorageClass(Src->getDLLStorageClass());
}
-static const GlobalObject *getBaseObject(const Constant &C) {
- // FIXME: We should probably return a base + offset pair for non-zero GEPs.
- return dyn_cast<GlobalObject>(C.stripPointerCasts());
-}
-
unsigned GlobalValue::getAlignment() const {
if (auto *GA = dyn_cast<GlobalAlias>(this)) {
// In general we cannot compute this at the IR level, but we try.
- if (const GlobalObject *GO = getBaseObject(*GA->getAliasee()))
+ if (const GlobalObject *GO = GA->getBaseObject())
return GO->getAlignment();
// FIXME: we should also be able to handle:
@@ -96,13 +91,23 @@ void GlobalObject::copyAttributesFrom(const GlobalValue *Src) {
const char *GlobalValue::getSection() const {
if (auto *GA = dyn_cast<GlobalAlias>(this)) {
// In general we cannot compute this at the IR level, but we try.
- if (const GlobalObject *GO = getBaseObject(*GA->getAliasee()))
+ if (const GlobalObject *GO = GA->getBaseObject())
return GO->getSection();
return "";
}
return cast<GlobalObject>(this)->getSection();
}
+Comdat *GlobalValue::getComdat() {
+ if (auto *GA = dyn_cast<GlobalAlias>(this)) {
+ // In general we cannot compute this at the IR level, but we try.
+ if (const GlobalObject *GO = GA->getBaseObject())
+ return const_cast<GlobalObject *>(GO)->getComdat();
+ return nullptr;
+ }
+ return cast<GlobalObject>(this)->getComdat();
+}
+
void GlobalObject::setSection(StringRef S) { Section = S; }
bool GlobalValue::isDeclaration() const {