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

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 09:29:46 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.
----------------
goldsteinn wrote:

Your argument is something like:

```
declare void @biz(ptr, ptr)
define ptr @bar(ptr %p) {
   ret ptr %p
}

define void @buz(ptr %p) {
  %p0 = call ptr @bar(ptr nonnull %p) readnone
  %p1 = call ptr @bar(ptr %p) readnone
  call void @biz(ptr %p0, ptr %p1)
}
```

Where we later propagate the `nonnull` to the return attr of `bar`?

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


More information about the llvm-commits mailing list