[Mlir-commits] [flang] [mlir] [mlir][GPU] Refactor GPUOps lowering (PR #188905)

Hocky Yudhiono llvmlistbot at llvm.org
Mon Mar 30 03:49:55 PDT 2026


================
@@ -0,0 +1,63 @@
+//===- LowerFunctionAttrsToLLVM.cpp - Lower func attrs to llvm.func -------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Conversion/LLVMCommon/LowerFunctionAttrsToLLVM.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/DebugLog.h"
+
+using namespace mlir;
+
+#define DEBUG_TYPE "lower-function-attrs-to-llvm"
+
+FailureOr<LowerLLVMFuncAttrs>
+mlir::lowerDiscardableAttrsForLLVMFunc(FunctionOpInterface func) {
+  MLIRContext *ctx = func->getContext();
+  LowerLLVMFuncAttrs lowered;
+
+  llvm::SmallDenseSet<StringRef> odsAttrNames(
+      LLVM::LLVMFuncOp::getAttributeNames().begin(),
+      LLVM::LLVMFuncOp::getAttributeNames().end());
+
+  NamedAttrList inherentAttrs;
+
+  for (const NamedAttribute &attr : func->getDiscardableAttrs()) {
+    StringRef attrName = attr.getName().strref();
+
+    // With properties-backed ops, `getDiscardableAttrs()` yields every entry in
+    // the raw attribute dictionary, which should only hold discardable
+    // attributes but can still contain duplicate keys for inherent attributes.
+    // Never forward those to llvm.func.
+    if (func->getInherentAttr(attrName).has_value())
+      continue;
----------------
hockyy wrote:

Let me remove it, I refactored some of the GPU inherent attributes.

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


More information about the Mlir-commits mailing list