[Mlir-commits] [mlir] [MLIR] Fuse locations of hoisted / merged constants (PR #74670)
Mehdi Amini
llvmlistbot at llvm.org
Wed Dec 6 20:44:23 PST 2023
================
@@ -19,6 +19,38 @@
using namespace mlir;
+// Fuse `foldedLocation` into the Location of `retainedOp`.
+// This will result in `retainedOp` having a FusedLoc with a StringAttr tag
+// "OpFold" to help trace the source of the fusion. If `retainedOp` already had
+// a FusedLoc with the same tag, `foldedLocation` will simply be appended to it.
+// Usage:
+// - When an op is deduplicated, fuse the location of the op to be removed into
+// the op that is retained.
+// - When an op is hoisted to the front/back of a block, fuse the location of
+// the parent region of the block into the hoisted op.
+static void appendFoldedLocation(Operation *retainedOp,
+ Location foldedLocation) {
+ constexpr std::string_view tag = "OpFold";
----------------
joker-eph wrote:
I think we usually use StringLiteral in LLVM: has there been a migration to std::string_view?
But even better, could you make this a StringAttr member of the `OperationFolder` class? (this could be a private method, or just take it an extra argument).
That way we'd avoid the repeated StringAttr creation in this function, and the string comparison line 38 would become a pointer comparison instead.
For the naming, we already have a "CSE" tag I think, it may be useful to reuse the naming here instead?
https://github.com/llvm/llvm-project/pull/74670
More information about the Mlir-commits
mailing list