[llvm] 4e0ca5e - GlobalValue: Move trivial getAddressSpace getter to header

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 12:25:49 PST 2022


Author: Matt Arsenault
Date: 2022-11-28T15:25:45-05:00
New Revision: 4e0ca5ef00cf63df7bbe22d679cbf3d8009976e6

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

LOG: GlobalValue: Move trivial getAddressSpace getter to header

Added: 
    

Modified: 
    llvm/include/llvm/IR/GlobalValue.h
    llvm/lib/IR/Globals.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h
index db290923dcf0c..04352193ec438 100644
--- a/llvm/include/llvm/IR/GlobalValue.h
+++ b/llvm/include/llvm/IR/GlobalValue.h
@@ -198,7 +198,9 @@ class GlobalValue : public Constant {
 
   GlobalValue(const GlobalValue &) = delete;
 
-  unsigned getAddressSpace() const;
+  unsigned getAddressSpace() const {
+    return getType()->getAddressSpace();
+  }
 
   enum class UnnamedAddr {
     None,

diff  --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 684cff831068c..7880369a2f98e 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -118,11 +118,6 @@ bool GlobalValue::canBenefitFromLocalAlias() const {
          !isa<GlobalIFunc>(this) && !isDeduplicateComdat(getComdat());
 }
 
-unsigned GlobalValue::getAddressSpace() const {
-  PointerType *PtrTy = getType();
-  return PtrTy->getAddressSpace();
-}
-
 void GlobalObject::setAlignment(MaybeAlign Align) {
   assert((!Align || *Align <= MaximumAlignment) &&
          "Alignment is greater than MaximumAlignment!");


        


More information about the llvm-commits mailing list