[PATCH] D110021: [DSE] Re-enable calloc transformation with extra care (PR25892)

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 18 03:39:30 PDT 2021


xbolva00 added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1864
+                                       m_Specific(Ptr),
+                                       m_Specific(Ptr->stripPointerCasts())),
+                                   m_Zero()),
----------------
m_Specific(Ptr->stripPointerCasts())),

Do we need it? Can it happen from C source?



```
float * ptr = (float*)malloc(N * sizeof(float));
                if (ptr != (float*)NULL) {
                    buf[i] = ptr;
                    memset(ptr,'\0',N);
                }
```

We have there:

```
  %5 = tail call noalias align 16 i8* @malloc(i64 %4) #3
  %6 = icmp eq i8* %5, null
```




================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1868
+              return false;
+            if (Pred != ICmpInst::ICMP_EQ && Pred != ICmpInst::ICMP_NE)
+              return false;
----------------
You dont need to check for NE, as EQ is canonical. EQ is NE with swapped BBs.


================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1870
+              return false;
+            return true;
+          };
----------------
Check that BB2 (False BB) must be MemsetBB?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110021/new/

https://reviews.llvm.org/D110021



More information about the llvm-commits mailing list