X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FGlobals.cpp;h=244e3e4baeedc6c1f5e7d95b9eb34943cf08885b;hb=7df1db57b3ae35afcc1df648f1446b7c7b60993b;hp=d5723c226a2d0a99ff3ff98a187e1c5d5e6c75bf;hpb=2d21b25393a461fbf8ab824889a6c56e1dd0b1cb;p=oota-llvm.git diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp index d5723c226a2..244e3e4baee 100644 --- a/lib/IR/Globals.cpp +++ b/lib/IR/Globals.cpp @@ -59,15 +59,10 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) { setDLLStorageClass(Src->getDLLStorageClass()); } -const GlobalObject *getBaseObject(const Constant &C) { - // FIXME: We should probably return a base + offset pair for non-zero GEPs. - return dyn_cast(C.stripPointerCasts()); -} - unsigned GlobalValue::getAlignment() const { if (auto *GA = dyn_cast(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(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(this)->getSection(); } +Comdat *GlobalValue::getComdat() { + if (auto *GA = dyn_cast(this)) { + // In general we cannot compute this at the IR level, but we try. + if (const GlobalObject *GO = GA->getBaseObject()) + return const_cast(GO)->getComdat(); + return nullptr; + } + return cast(this)->getComdat(); +} + void GlobalObject::setSection(StringRef S) { Section = S; } bool GlobalValue::isDeclaration() const { @@ -290,7 +295,7 @@ void GlobalAlias::eraseFromParent() { } void GlobalAlias::setAliasee(Constant *Aliasee) { - assert(!Aliasee || Aliasee->getType() == getType() && + assert((!Aliasee || Aliasee->getType() == getType()) && "Alias and aliasee types should match!"); setOperand(0, Aliasee); }