[PATCH] D28300: [InstCombine] Fix address space handling when removing allocas

James Price via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 09:15:24 PST 2017


jprice added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineInternal.h:445
+  /// pointer with a new value, propagating the new address space to all users.
+  void replacePtrUsesAndPropagateAddrSpace(Value *OldPtr, Value *NewPtr) {
+    unsigned NewAddrSpace = NewPtr->getType()->getPointerAddressSpace();
----------------
arsenm wrote:
> This could also be a utility somewhere more general
I did wonder this, but currently this function makes several assumptions that are specific to the particular optimisation that uses it (e.g. lack of handling for certain instructions as per comment below). I think it may need a fair bit more work to make it more general purpose.


================
Comment at: lib/Transforms/InstCombine/InstCombineInternal.h:505-507
+      } else {
+        assert(false && "Can't update address space for this instruction");
+      }
----------------
arsenm wrote:
> I think you'll also need to handle AtomicRMW and cmpxchg
At the moment, the `isOnlyCopiedFromConstantGlobal` method doesn't allow this optimisation to occur if these instructions are present.


https://reviews.llvm.org/D28300





More information about the llvm-commits mailing list