[llvm] [SPIR-V] Cast ptr kernel args to i8* when used as Store's value operand (PR #78603)

Natalie Chouinard via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 13:03:43 PST 2024


================
@@ -282,7 +283,26 @@ void SPIRVEmitIntrinsics::insertPtrCastInstr(Instruction *I) {
   Value *Pointer;
   Type *ExpectedElementType;
   unsigned OperandToReplace;
-  if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
+  bool AllowCastingToChar = false;
+
+  StoreInst *SI = dyn_cast<StoreInst>(I);
+  if (SI && F->getCallingConv() == CallingConv::SPIR_KERNEL &&
+      SI->getValueOperand()->getType()->isPointerTy() &&
+      isa<Argument>(SI->getValueOperand())) {
+    Argument *Arg = dyn_cast<Argument>(SI->getValueOperand());
+    MDString *ArgType = getOCLKernelArgType(*Arg->getParent(), Arg->getArgNo());
----------------
sudonatalie wrote:

You should be able to safely use `cast<>` here instead of  `dyn_cast` since you have the `isa` check.

https://github.com/llvm/llvm-project/pull/78603


More information about the llvm-commits mailing list