[Mlir-commits] [mlir] [MLIR] Erase location of folded constants (PR #75415)

Billy Zhu llvmlistbot at llvm.org
Wed Dec 20 15:09:36 PST 2023


================
@@ -318,6 +327,7 @@ OperationFolder::tryGetOrCreateConstant(ConstantMap &uniquedConstants,
     notifyRemoval(constOp);
     rewriter.eraseOp(constOp);
     referencedDialects[existingOp].push_back(dialect);
+    existingOp->setLoc(erasedFoldedLocation);
----------------
zyx-billy wrote:

Same logic applies here (see test case `materialize_different_dialect` below).

Though now I think we can make this a bit more explicit by still having the user pass in a location, but if the new location doesn't match the existing location, then we erase it. That way it's more clear what's going on.

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


More information about the Mlir-commits mailing list