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

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 20 05:16:33 PDT 2021


yurai007 added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1864
+                                       m_Specific(Ptr),
+                                       m_Specific(Ptr->stripPointerCasts())),
+                                   m_Zero()),
----------------
xbolva00 wrote:
> 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
> ```
> 
> 
Right, given that memset always takes i8* (modulo alignment)  no reason to assume in-between casting.


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