[Mlir-commits] [mlir] [MLIR] Flatten fused locations when merging constants. (PR #75218)

Benjamin Chetioui llvmlistbot at llvm.org
Wed Dec 13 02:22:27 PST 2023


================
@@ -331,6 +331,39 @@ OperationFolder::tryGetOrCreateConstant(ConstantMap &uniquedConstants,
   return newIt.first->second;
 }
 
+/// Helper that flattens nested fused locations to a single fused location.
+/// Fused locations nested under non-fused locations are not flattened, and
+/// calling this on non-fused locations is a no-op as a result.
+///
+/// Fused locations are only flattened into parent fused locations if the
+/// child fused location has no metadata, or if the metadata of the parent and
+/// child fused locations are the same---this to avoid breaking cases where
+/// metadata matter.
+static Location FlattenFusedLocationRecursively(const Location loc) {
+  if (auto fusedLoc = dyn_cast<FusedLoc>(loc)) {
----------------
bchetioui wrote:

Done in [new PR](https://github.com/llvm/llvm-project/pull/75312).

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


More information about the Mlir-commits mailing list