[Mlir-commits] [mlir] [mlir][llvm] Gate unhandled function metadata warning (PR #221895)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Sep 8 00:22:47 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-llvm

Author: Tobias Gysi (gysit)

<details>
<summary>Changes</summary>

Emit the warning for unhandled function metadata only when expensive warnings are requested, matching how the flag is already used for instruction metadata.

---
Full diff: https://github.com/llvm/llvm-project/pull/221895.diff


3 Files Affected:

- (modified) mlir/lib/Target/LLVMIR/ModuleImport.cpp (+2) 
- (modified) mlir/test/Target/LLVMIR/Import/function-attributes.ll (+1-1) 
- (modified) mlir/test/Target/LLVMIR/Import/function-metadata.ll (+2-2) 


``````````diff
diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index bc4ca805b9d7b..e9aa7e310c6e0 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -3381,6 +3381,8 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
 
     llvm::MDNode *metadataNode = node;
     auto emitUnhandledFunctionMetadataWarning = [&]() {
+      if (!emitExpensiveWarnings)
+        return;
       emitWarning(funcOp.getLoc())
           << "unhandled function metadata: "
           << diagMD(metadataNode, llvmModule.get()) << " on " << diag(*func);
diff --git a/mlir/test/Target/LLVMIR/Import/function-attributes.ll b/mlir/test/Target/LLVMIR/Import/function-attributes.ll
index 060b4c51baff5..f05144f806ca3 100644
--- a/mlir/test/Target/LLVMIR/Import/function-attributes.ll
+++ b/mlir/test/Target/LLVMIR/Import/function-attributes.ll
@@ -1,4 +1,4 @@
-; RUN: mlir-translate -import-llvm -split-input-file %s --verify-diagnostics | FileCheck %s
+; RUN: mlir-translate -import-llvm -emit-expensive-warnings -split-input-file %s --verify-diagnostics | FileCheck %s
 
 ; CHECK: llvm.func internal @func_internal
 define internal void @func_internal() {
diff --git a/mlir/test/Target/LLVMIR/Import/function-metadata.ll b/mlir/test/Target/LLVMIR/Import/function-metadata.ll
index f74f1bb1216c7..2b244835d6a1d 100644
--- a/mlir/test/Target/LLVMIR/Import/function-metadata.ll
+++ b/mlir/test/Target/LLVMIR/Import/function-metadata.ll
@@ -1,5 +1,5 @@
-; RUN: mlir-translate -import-llvm -split-input-file %s | FileCheck %s
-; RUN: mlir-translate -import-llvm -split-input-file %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN
+; RUN: mlir-translate -import-llvm -split-input-file %s --verify-diagnostics | FileCheck %s
+; RUN: mlir-translate -import-llvm -emit-expensive-warnings -split-input-file %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN
 
 ; CHECK-LABEL: llvm.func @repeated_type_metadata
 ; CHECK-SAME: function_metadata

``````````

</details>


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


More information about the Mlir-commits mailing list