[PATCH] Don't use default address space arguments in SROA

Matt Arsenault Matthew.Arsenault at amd.com
Thu Dec 12 13:58:34 PST 2013


Hi chandlerc,

This doesn't change anything since alloca is always address space 0. This is a step towards removing the default arguments for the pointer getting functions.


http://llvm-reviews.chandlerc.com/D2396

Files:
  lib/Transforms/Scalar/SROA.cpp

Index: lib/Transforms/Scalar/SROA.cpp
===================================================================
--- lib/Transforms/Scalar/SROA.cpp
+++ lib/Transforms/Scalar/SROA.cpp
@@ -2030,8 +2030,9 @@
   Value *getAdjustedAllocaPtr(IRBuilderTy &IRB, uint64_t Offset,
                               Type *PointerTy) {
     assert(Offset >= NewAllocaBeginOffset);
-    return getAdjustedPtr(IRB, DL, &NewAI, APInt(DL.getPointerSizeInBits(),
-                                                 Offset - NewAllocaBeginOffset),
+    return getAdjustedPtr(IRB, DL, &NewAI,
+                          APInt(DL.getPointerTypeSizeInBits(PointerTy),
+                                Offset - NewAllocaBeginOffset),
                           PointerTy);
   }
 
@@ -2107,6 +2108,8 @@
 
     uint64_t Size = NewEndOffset - NewBeginOffset;
 
+    unsigned AS = LI.getPointerAddressSpace();
+
     Type *TargetTy = IsSplit ? Type::getIntNTy(LI.getContext(), Size * 8)
                              : LI.getType();
     bool IsPtrAdjusted = false;
@@ -2120,7 +2123,7 @@
       V = IRB.CreateAlignedLoad(&NewAI, NewAI.getAlignment(),
                                 LI.isVolatile(), "load");
     } else {
-      Type *LTy = TargetTy->getPointerTo();
+      Type *LTy = TargetTy->getPointerTo(AS);
       V = IRB.CreateAlignedLoad(
           getAdjustedAllocaPtr(IRB, NewBeginOffset, LTy),
           getOffsetTypeAlign(TargetTy, NewBeginOffset - NewAllocaBeginOffset),
@@ -2145,7 +2148,7 @@
       // the computed value, and then replace the placeholder with LI, leaving
       // LI only used for this computation.
       Value *Placeholder
-        = new LoadInst(UndefValue::get(LI.getType()->getPointerTo()));
+        = new LoadInst(UndefValue::get(LI.getType()->getPointerTo(AS)));
       V = insertInteger(DL, IRB, Placeholder, V, NewBeginOffset,
                         "insert");
       LI.replaceAllUsesWith(V);
@@ -2256,8 +2259,9 @@
       NewSI = IRB.CreateAlignedStore(V, &NewAI, NewAI.getAlignment(),
                                      SI.isVolatile());
     } else {
+      unsigned AS = SI.getPointerAddressSpace();
       Value *NewPtr = getAdjustedAllocaPtr(IRB, NewBeginOffset,
-                                           V->getType()->getPointerTo());
+                                           V->getType()->getPointerTo(AS));
       NewSI = IRB.CreateAlignedStore(
           V, NewPtr, getOffsetTypeAlign(
                          V->getType(), NewBeginOffset - NewAllocaBeginOffset),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2396.1.patch
Type: text/x-patch
Size: 2496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131212/e727fc62/attachment.bin>


More information about the llvm-commits mailing list