<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Redundant store to calloc'ed memory not eliminated"
   href="http://llvm.org/bugs/show_bug.cgi?id=19873">19873</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Redundant store to calloc'ed memory not eliminated
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>listmail@philipreames.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>calloc returns zero initialized memory.  As a result, any store of a zero value
to this memory is redundant and can be eliminated.  

Here's an IR test case:
declare noalias i8* @calloc(i64, i64)

; Function Attrs: nounwind uwtable
define noalias i32* @test_store() {
  %1 = tail call noalias i8* @calloc(i64 1, i64 4) #2
  %2 = bitcast i8* %1 to i32*
  ; This store is redundant
  store i32 0, i32* %2, align 4
  ret i32* %2
}

This was generated from Clang 3.4 from the following C++ program:
#include <cstdlib>

extern "C"
int* test_store() {
  int* a = (int*)calloc(1,sizeof(int));
  a[0] = 0;
  return a;
}

I have confirmed that the IR fragement above survives being run through a TOT
"opt -O3" invocation.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>