[llvm] dce53d7 - [IRMover] Use GlobalValue::getAddressSpace instead of directly from its type [NFC]

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 13:54:56 PST 2019


Author: Teresa Johnson
Date: 2019-11-05T13:54:41-08:00
New Revision: dce53d71987d9c44360d8a8d995ca2ad042f990f

URL: https://github.com/llvm/llvm-project/commit/dce53d71987d9c44360d8a8d995ca2ad042f990f
DIFF: https://github.com/llvm/llvm-project/commit/dce53d71987d9c44360d8a8d995ca2ad042f990f.diff

LOG: [IRMover] Use GlobalValue::getAddressSpace instead of directly from its type [NFC]

Summary: Change the old form of G->getType()->getAddressSpace() to the new G->getAddressSpace() (underneath does the same).

Patch by Ehud Katz <ehudkatz at gmail.com>

Reviewers: tejohnson, chandlerc

Reviewed By: tejohnson

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

Added: 
    

Modified: 
    llvm/lib/Linker/IRMover.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 6784d81595e5..1cef0e84a308 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -628,7 +628,7 @@ GlobalVariable *IRLinker::copyGlobalVariableProto(const GlobalVariable *SGVar) {
                          SGVar->isConstant(), GlobalValue::ExternalLinkage,
                          /*init*/ nullptr, SGVar->getName(),
                          /*insertbefore*/ nullptr, SGVar->getThreadLocalMode(),
-                         SGVar->getType()->getAddressSpace());
+                         SGVar->getAddressSpace());
   NewDGV->setAlignment(MaybeAlign(SGVar->getAlignment()));
   NewDGV->copyAttributesFrom(SGVar);
   return NewDGV;
@@ -671,11 +671,11 @@ IRLinker::copyGlobalIndirectSymbolProto(const GlobalIndirectSymbol *SGIS) {
   auto *Ty = TypeMap.get(SGIS->getValueType());
   GlobalIndirectSymbol *GIS;
   if (isa<GlobalAlias>(SGIS))
-    GIS = GlobalAlias::create(Ty, SGIS->getType()->getPointerAddressSpace(),
+    GIS = GlobalAlias::create(Ty, SGIS->getAddressSpace(),
                               GlobalValue::ExternalLinkage, SGIS->getName(),
                               &DstM);
   else
-    GIS = GlobalIFunc::create(Ty, SGIS->getType()->getPointerAddressSpace(),
+    GIS = GlobalIFunc::create(Ty, SGIS->getAddressSpace(),
                               GlobalValue::ExternalLinkage, SGIS->getName(),
                               nullptr, &DstM);
   GIS->copyAttributesFrom(SGIS);
@@ -697,12 +697,12 @@ GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV,
           Function::Create(cast<FunctionType>(TypeMap.get(SGV->getValueType())),
                            GlobalValue::ExternalLinkage, SGV->getName(), &DstM);
     else
-      NewGV = new GlobalVariable(
-          DstM, TypeMap.get(SGV->getValueType()),
-          /*isConstant*/ false, GlobalValue::ExternalLinkage,
-          /*init*/ nullptr, SGV->getName(),
-          /*insertbefore*/ nullptr, SGV->getThreadLocalMode(),
-          SGV->getType()->getAddressSpace());
+      NewGV =
+          new GlobalVariable(DstM, TypeMap.get(SGV->getValueType()),
+                             /*isConstant*/ false, GlobalValue::ExternalLinkage,
+                             /*init*/ nullptr, SGV->getName(),
+                             /*insertbefore*/ nullptr,
+                             SGV->getThreadLocalMode(), SGV->getAddressSpace());
   }
 
   if (ForDefinition)
@@ -918,7 +918,7 @@ IRLinker::linkAppendingVarProto(GlobalVariable *DstGV,
   GlobalVariable *NG = new GlobalVariable(
       DstM, NewType, SrcGV->isConstant(), SrcGV->getLinkage(),
       /*init*/ nullptr, /*name*/ "", DstGV, SrcGV->getThreadLocalMode(),
-      SrcGV->getType()->getAddressSpace());
+      SrcGV->getAddressSpace());
 
   NG->copyAttributesFrom(SrcGV);
   forceRenaming(NG, SrcGV->getName());


        


More information about the llvm-commits mailing list