[llvm] [EarlyCSE] De-Duplicate callsites with differing attrs (PR #110929)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 09:13:48 PDT 2024


================
@@ -1632,6 +1639,18 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
           LLVM_DEBUG(dbgs() << "Skipping due to debug counter\n");
           continue;
         }
+        // We probably don't need a complete itersection of attrs between
+        // InVal.first and Inst.
+        // We only CSE readonly functions that have the same memory state and
+        // its not clear that any non-return *callsite* attribute can create
+        // side-effects. Likewise this implies when checking equality of
+        // callsite for CSEing, we can probably ignore all non-return attrs.
----------------
nikic wrote:

This is not right, there is really no distinction between return and parameter attributes here. Just move the attribute to the parameter and have the function return it.

There *is* a distinction between attributes that imply poison and those that imply UB, in that the latter can be unconditionally preserved from the first call-site, while the former need intersection. But just intersecting everything is conservatively correct.

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


More information about the llvm-commits mailing list