================
@@ -99,11 +99,23 @@ template <typename... TargetOps> class StdRecognizer {
     constexpr unsigned numArgs = TargetOp::getNumArgs();
     TargetOp op =
         buildCall<TargetOp>(builder, call, 
std::make_index_sequence<numArgs>());
-    // The raised operation keeps every call attribute except the callee,
-    // which it carries as original_fn, so lowering back loses nothing.
-    for (mlir::NamedAttribute attr : call->getAttrs())
-      if (attr.getName() != call.getCalleeAttrName())
-        op->setAttr(attr.getName(), attr.getValue());
+    // Preserve call properties that are not represented by the raised op so
+    // LoweringPrepare can reconstruct the original call.
+    auto preserveCallProperty = [&](mlir::StringAttr name,
+                                    mlir::Attribute value) {
+      if (value)
+        op->setDiscardableAttr(name, value);
+    };
+    preserveCallProperty(call.getNothrowAttrName(), call.getNothrowAttr());
----------------
joker-eph wrote:

There is a`walkInherentAttributes` helper which can walk all the inherent 
attributes generically, however how do know that the receiving op expects 
always exactly the same set?

https://github.com/llvm/llvm-project/pull/223048
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to