[PATCH] Fix crash when looking up the addrspace of GEPs with vector types

Matt Arsenault Matthew.Arsenault at amd.com
Sun Aug 31 10:09:51 PDT 2014


I'm kind of surprised this was broken. It would probably be better to come up with a testcase where this breaks in a more fundamental pass like instcombine

================
Comment at: include/llvm/IR/Instructions.h:890
@@ -889,3 +889,6 @@
   unsigned getPointerAddressSpace() const {
-    return getPointerOperandType()->getPointerAddressSpace();
   }
----------------
This one looks correct already, and this change should be unnecessary. getPointerAddressSpace() already calls getScalarType()

================
Comment at: include/llvm/IR/Operator.h:405-408
@@ -404,3 +404,6 @@
   unsigned getPointerAddressSpace() const {
-    return cast<PointerType>(getPointerOperandType())->getAddressSpace();
+    Type *Ty = getPointerOperandType();
+    if (VectorType *VecTy = dyn_cast<VectorType>(Ty))
+      Ty = VecTy->getElementType();
+    return cast<PointerType>(Ty)->getAddressSpace();
   }
----------------
This is a correct fix, but this should use Ty->getPointerAddressSpace() like everywhere else

http://reviews.llvm.org/D5136






More information about the llvm-commits mailing list