[Mlir-commits] [mlir] [mlir][LLVMIR] Add LLVMDialect check in `DIScopeForLLVMFuncOp` (PR #110427)
Longsheng Mou
llvmlistbot at llvm.org
Thu Oct 3 02:06:42 PDT 2024
https://github.com/CoTinker updated https://github.com/llvm/llvm-project/pull/110427
>From af1d510589ba526ac81d3e8605fb55f3ffb56acb Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Sun, 29 Sep 2024 23:13:39 +0800
Subject: [PATCH] [mlir][LLVMIR] Add LLVMDialect check in
`DIScopeForLLVMFuncOp`
This PR adds an LLVMDialect check in `DIScopeForLLVMFuncOp` to
prevent crashes.
---
mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
index 2cfaffa7c8efce..b276e06f93c612 100644
--- a/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
+++ b/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
@@ -91,6 +91,10 @@ struct DIScopeForLLVMFuncOp
Location loc = module.getLoc();
MLIRContext *context = &getContext();
+ if (!context->getLoadedDialect<LLVM::LLVMDialect>()) {
+ emitError(loc, "LLVM dialect is not loaded.");
+ return signalPassFailure();
+ }
// To find a DICompileUnitAttr attached to a parent (the module for
// example), otherwise create a default one.
More information about the Mlir-commits
mailing list