[opaque pointer types] Add an explicit value type to GlobalObject

This is needed by all GlobalObjects (GlobalAlias, Function,
GlobalVariable), see the GlobalObject::getValueType which is used in
many places. If at some point that can be removed, then we can remove
this member.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247621 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2015-09-14 21:47:27 +00:00
parent a0f3964ea6
commit 6602ba5dcf
3 changed files with 10 additions and 12 deletions

View File

@ -27,13 +27,10 @@ class GlobalObject : public GlobalValue {
GlobalObject(const GlobalObject &) = delete;
protected:
GlobalObject(PointerType *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
LinkageTypes Linkage, const Twine &Name) = delete;
GlobalObject(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
LinkageTypes Linkage, const Twine &Name,
unsigned AddressSpace = 0)
: GlobalValue(PointerType::get(Ty, AddressSpace), VTy, Ops, NumOps,
Linkage, Name),
: GlobalValue(Ty, VTy, Ops, NumOps, Linkage, Name, AddressSpace),
ObjComdat(nullptr) {
setGlobalValueSubClassData(0);
}

View File

@ -65,15 +65,16 @@ public:
};
protected:
GlobalValue(PointerType *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
LinkageTypes Linkage, const Twine &Name)
: Constant(Ty, VTy, Ops, NumOps), Linkage(Linkage),
Visibility(DefaultVisibility), UnnamedAddr(0),
DllStorageClass(DefaultStorageClass),
GlobalValue(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace)
: Constant(PointerType::get(Ty, AddressSpace), VTy, Ops, NumOps),
ValueType(Ty), Linkage(Linkage), Visibility(DefaultVisibility),
UnnamedAddr(0), DllStorageClass(DefaultStorageClass),
ThreadLocal(NotThreadLocal), IntID((Intrinsic::ID)0U), Parent(nullptr) {
setName(Name);
}
Type *ValueType;
// Note: VC++ treats enums as signed, so an extra bit is required to prevent
// Linkage and Visibility from turning into negative values.
LinkageTypes Linkage : 5; // The linkage of this global
@ -184,7 +185,7 @@ public:
/// Global values are always pointers.
PointerType *getType() const { return cast<PointerType>(User::getType()); }
Type *getValueType() const { return getType()->getElementType(); }
Type *getValueType() const { return ValueType; }
static LinkageTypes getLinkOnceLinkage(bool ODR) {
return ODR ? LinkOnceODRLinkage : LinkOnceAnyLinkage;

View File

@ -234,8 +234,8 @@ void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) {
GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
const Twine &Name, Constant *Aliasee,
Module *ParentModule)
: GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalAliasVal,
&Op<0>(), 1, Link, Name) {
: GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name,
AddressSpace) {
Op<0>() = Aliasee;
if (ParentModule)