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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 19:56:39 PDT 2024


================
@@ -1307,6 +1307,23 @@ static void combineIRFlags(Instruction &From, Value *To) {
         (I->hasPoisonGeneratingFlags() && !programUndefinedIfPoison(I)))
       I->andIRFlags(&From);
   }
+  if (isa<CallBase>(&From) && isa<CallBase>(To)) {
+    // NB: Intersection of attrs between InVal.first and Inst is overly
+    // conservative. Since we only CSE readonly functions that have the same
+    // memory state, we can preserve (or possibly in some cases combine)
+    // more attributes. Likewise this implies when checking equality of
+    // callsite for CSEing, we can probably ignore more attributes.
+    // Generally poison generating attributes need to be handled with more
+    // care as they can create *new* UB if preserved/combined and violated.
+    // Attributes that imply immediate UB on the otherhand would have been
----------------
dtcxzyw wrote:

```suggestion
    // Attributes that imply immediate UB on the other hand would have been
```

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


More information about the llvm-commits mailing list