[PATCH] D15982: [rs4gc] Optionally directly relocated vector of pointers

Manuel Jacob via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 18:12:30 PST 2016


mjacob added inline comments.

================
Comment at: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:1331-1342
@@ +1330,14 @@
+    assert(isHandledGCPointerType(Ty));
+    if (auto *PT = dyn_cast<PointerType>(Ty)) {
+      auto AS = PT->getAddressSpace();
+      Type *Types[] = {Type::getInt8PtrTy(M->getContext(), AS)};
+      return Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types);
+    }
+    auto *VT = cast<VectorType>(Ty);
+    auto *PT = cast<PointerType>(VT->getElementType());
+    auto AS = PT->getAddressSpace();
+    
+    Type *Types[] = {VectorType::get(Type::getInt8PtrTy(M->getContext(), AS),
+                                     VT->getNumElements())};
+    return Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types);
+  };
----------------
You can hoist the construction of the i8 pointer in the correct address space before the conditional by using `Type::getInt8PtrTy(M->getContext(), Ty->getPointerAddressSpace())`. Then you could further simplify the code by sinking the call to `Intrinsic::getDeclaration()` to a common path.

The resulting code would be similar to this:
```
Type *Int8Ptr = Type::getInt8PtrTy(M->getContext(), Ty->getPointerAddressSpace());
if (VectorType *VT = dyn_cast<VectorType>(Ty))
  Int8Ptr = VectorType::get(Int8Ptr, VT->getNumElements());
return Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, {Int8Ptr});
```


http://reviews.llvm.org/D15982





More information about the llvm-commits mailing list