[clang] [llvm] [clang-tools-extra] [mlir] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

Fabian Mora via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 13 16:48:02 PST 2023


================
@@ -377,10 +379,17 @@ llvm::LaunchKernel::createKernelLaunch(mlir::gpu::LaunchFuncOp op,
   if (!binary)
     return op.emitError() << "Couldn't find the binary: " << binaryIdentifier;
 
+  auto binaryVar = dyn_cast<llvm::GlobalVariable>(binary);
+  llvm::Constant *binaryInit = binaryVar->getInitializer();
+  auto binaryDataSeq = dyn_cast<llvm::ConstantDataSequential>(binaryInit);
----------------
fabianmcg wrote:

Some form of check must be placed on the pointers:
```suggestion
  auto binaryVar = dyn_cast<llvm::GlobalVariable>(binary);
  assert(binaryVar && "expected a global variable");
  llvm::Constant *binaryInit = binaryVar->getInitializer();
  auto binaryDataSeq = dyn_cast_or_null<llvm::ConstantDataSequential>(binaryInit);
  assert(binaryDataSeq && "expected a valid initializer");
```

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


More information about the cfe-commits mailing list