[llvm] [DSE] Apply initializes attribute to DSE (PR #107282)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 03:23:30 PDT 2024


================
@@ -1602,7 +1731,17 @@ struct DSEState {
 
       // Uses which may read the original MemoryDef mean we cannot eliminate the
       // original MD. Stop walk.
-      if (isReadClobber(MaybeDeadLoc, UseInst)) {
+      // If KillingDef is a CallInst with "initializes" attribute, the reads in
+      // Callee would be dominated by initializations, so this should be safe.
+      bool IsKillingDefFromInitAttr = false;
+      if (IsInitializesAttrMemLoc) {
+        if (KillingI == UseInst &&
+            KillingUndObj == getUnderlyingObject(MaybeDeadLoc.Ptr)) {
----------------
nikic wrote:

It looks like this inner if is untested (test pass if I replace the condition with true).

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


More information about the llvm-commits mailing list