[MLIR][OpenMP] Add check for appropriate module operation during convertFlagsAttr
authorAndrew Gozillon <Andrew.Gozillon@amd.com>
Thu, 27 Apr 2023 13:18:57 +0000 (08:18 -0500)
committerAndrew Gozillon <Andrew.Gozillon@amd.com>
Thu, 27 Apr 2023 14:23:39 +0000 (09:23 -0500)
Checks if the operation the attirbute resides on is an ModuleOp otherwise it fails.

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

index 52c0755..200f7d9 100644 (file)
@@ -1547,6 +1547,9 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
 /// be passed as flags to the frontend, otherwise they are set to default
 LogicalResult convertFlagsAttr(Operation *op, mlir::omp::FlagsAttr attribute,
                                LLVM::ModuleTranslation &moduleTranslation) {
+  if (!cast<mlir::ModuleOp>(op))
+    return failure();
+  
   llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
 
   ompBuilder->createGlobalFlag(