[NFC] Use Aliasee to determine Type and AddrSpace in GlobalAlias::create()
authorArthur Eubanks <aeubanks@google.com>
Sun, 2 May 2021 04:44:32 +0000 (21:44 -0700)
committerArthur Eubanks <aeubanks@google.com>
Sun, 2 May 2021 18:50:08 +0000 (11:50 -0700)
As opposed to going through the Aliasee type.

For opaque pointers, we're trying to remove uses of PointerType::getElementType().

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D101715

llvm/lib/IR/Globals.cpp

index c2cbe7d..b1c6dcc 100644 (file)
@@ -502,8 +502,7 @@ GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
 
 GlobalAlias *GlobalAlias::create(LinkageTypes Link, const Twine &Name,
                                  GlobalValue *Aliasee) {
-  PointerType *PTy = Aliasee->getType();
-  return create(PTy->getElementType(), PTy->getAddressSpace(), Link, Name,
+  return create(Aliasee->getValueType(), Aliasee->getAddressSpace(), Link, Name,
                 Aliasee);
 }