[Mlir-commits] [mlir] [mlir] Migrate users to explicitly discardable/inherent attribute APIs (PR #217233)

Igor Wodiany llvmlistbot at llvm.org
Wed Aug 19 02:55:59 PDT 2026


================
@@ -294,11 +294,34 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, const TypeConverter &typeConverter,
   auto newFuncOp = spirv::FuncOp::create(
       rewriter, funcOp.getLoc(), funcOp.getName(),
       rewriter.getFunctionType(signatureConverter.getConvertedTypes(), {}));
-  for (const auto &namedAttr : funcOp->getAttrs()) {
+  newFuncOp.setArgAttrsAttr(funcOp.getArgAttrsAttr());
+  newFuncOp.setResAttrsAttr(funcOp.getResAttrsAttr());
+  cast<SymbolOpInterface>(newFuncOp.getOperation())
+      .setVisibility(
+          cast<SymbolOpInterface>(funcOp.getOperation()).getVisibility());
+
+  auto copyGPUProperty = [&](StringAttr name, Attribute value) {
+    if (value)
+      newFuncOp->setDiscardableAttr(name, value);
+  };
+  copyGPUProperty(funcOp.getWorkgroupAttribAttrsAttrName(),
+                  funcOp.getWorkgroupAttribAttrsAttr());
+  copyGPUProperty(funcOp.getPrivateAttribAttrsAttrName(),
+                  funcOp.getPrivateAttribAttrsAttr());
+  copyGPUProperty(funcOp.getKnownBlockSizeAttrName(),
+                  funcOp.getKnownBlockSizeAttr());
+  copyGPUProperty(funcOp.getKnownGridSizeAttrName(),
+                  funcOp.getKnownGridSizeAttr());
+  copyGPUProperty(funcOp.getKnownClusterSizeAttrName(),
+                  funcOp.getKnownClusterSizeAttr());
+  copyGPUProperty(funcOp.getWorkgroupAttributionsAttrName(),
+                  funcOp.getWorkgroupAttributionsAttr());
+  for (const auto &namedAttr :
----------------
IgWod wrote:

nit: `namedAttr` -> `discardableAttr` since we deal we named attributes (if my understanding is right) above the loop.

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


More information about the Mlir-commits mailing list