https://llvm.org/bugs/show_bug.cgi?id=25892

            Bug ID: 25892
           Summary: [LIR] Misses opportunity to convert malloc + memset
                    zero -> calloc
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedb...@nondot.org
          Reporter: mcros...@codeaurora.org
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

float *foo(int size) {
  float *fdata;
  fdata = (float *) malloc(size);
  if (fdata == NULL) {
    fprintf(stderr, "Can't allocate data array.\n");
    exit(1);
  }
  memset(fdata, 0, size);
  return fdata;
}

We should be able to convert the malloc into a calloc and remove the memset.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to