[LLVMbugs] [Bug 19873] New: Redundant store to calloc'ed memory not eliminated

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 27 17:17:21 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19873

            Bug ID: 19873
           Summary: Redundant store to calloc'ed memory not eliminated
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: listmail at philipreames.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140528/392309f9/attachment.html>


More information about the llvm-bugs mailing list