[llvm] [GVN] Restrict equality propagation for pointers (PR #82458)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 20:00:45 PDT 2024


================
@@ -433,12 +433,29 @@ unsigned replaceNonLocalUsesWith(Instruction *From, Value *To);
 
 /// Replace each use of 'From' with 'To' if that use is dominated by
 /// the given edge.  Returns the number of replacements made.
-unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
+unsigned replaceDominatedUsesWith(Value *From, Value *To, const DataLayout &DL,
+                                  DominatorTree &DT,
                                   const BasicBlockEdge &Edge);
 /// Replace each use of 'From' with 'To' if that use is dominated by
 /// the end of the given BasicBlock. Returns the number of replacements made.
-unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT,
-                                  const BasicBlock *BB);
+unsigned replaceDominatedUsesWith(Value *From, Value *To, const DataLayout &DL,
+                                  DominatorTree &DT, const BasicBlock *BB);
+/// Replace each use of 'From' with 'To' if that use is dominated by
+/// the given edge and the callback ShouldReplace returns true. Returns the
+/// number of replacements made.
+unsigned replaceDominatedUsesWithIf(
+    Value *From, Value *To, const DataLayout &DL, DominatorTree &DT,
+    const BasicBlockEdge &Edge,
+    function_ref<bool(const Use &U, const Value *To, const DataLayout &DL)>
+        ShouldReplace);
+/// Replace each use of 'From' with 'To' if that use is dominated by
+/// the end of the given BasicBlock and the callback ShouldReplace returns true.
+/// Returns the number of replacements made.
+unsigned replaceDominatedUsesWithIf(
+    Value *From, Value *To, const DataLayout &DL, DominatorTree &DT,
+    const BasicBlock *BB,
+    function_ref<bool(const Use &U, const Value *To, const DataLayout &DL)>
+        ShouldReplace);
----------------
nikic wrote:

I don't think that these APIs should be taking a DataLayout argument, as they themselves do not use it. You should capture DL in the callback you pass to these APIs instead.

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


More information about the llvm-commits mailing list