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

Tobias Gysi llvmlistbot at llvm.org
Tue Sep 8 00:22:11 PDT 2026


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

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

>From acbfceca4912c7d923d0c164046a20baa0e936e8 Mon Sep 17 00:00:00 2001
From: Tobias Gysi <tobias.gysi at nextsilicon.com>
Date: Tue, 8 Sep 2026 09:10:01 +0200
Subject: [PATCH] [mlir][llvm] Gate unhandled function metadata warning

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply at anthropic.com>
---
 mlir/lib/Target/LLVMIR/ModuleImport.cpp               | 2 ++
 mlir/test/Target/LLVMIR/Import/function-attributes.ll | 2 +-
 mlir/test/Target/LLVMIR/Import/function-metadata.ll   | 4 ++--
 3 files changed, 5 insertions(+), 3 deletions(-)

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



More information about the Mlir-commits mailing list