R600/SI: Fix promote alloca pass breaking addrspacecast
[oota-llvm.git] / lib / Target / R600 / AMDGPUPromoteAlloca.cpp
index 620925a62b135e75bd46479da0b067c050f72da5..4a6c10455df989aaf1617a96bad673dd4bc6132e 100644 (file)
@@ -329,6 +329,13 @@ void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
     if (!Call) {
       Type *EltTy = V->getType()->getPointerElementType();
       PointerType *NewTy = PointerType::get(EltTy, AMDGPUAS::LOCAL_ADDRESS);
+
+      // The operand's value should be corrected on its own.
+      if (isa<AddrSpaceCastInst>(V))
+        continue;
+
+      // FIXME: It doesn't really make sense to try to do this for all
+      // instructions.
       V->mutateType(NewTy);
       continue;
     }