[LLVMbugs] [Bug 1201] NEW: Unused malloc/free don't get optimized

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Feb 15 05:59:43 PST 2007


           Summary: Unused malloc/free don't get optimized
           Product: libraries
           Version: 1.9
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Miscellaneous Instrumentation passes
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nicola.lugato at gmail.com

The optimizer doesn't remove malloc/free instructions when the allocated memory
is not used.

My example (but it does the same with simply a couple of malloc/free instructions)

Before optimization:

int %main(int %argc, ubyte** %argv)
%c_19 = alloca ubyte*
%malloc_206  = malloc ubyte, uint 10
store ubyte* %malloc_206, ubyte** %c_19
%tmp_207 = load ubyte** %c_19
free ubyte* %tmp_207

ret int 0

After optimization:

int %main(int %argc, ubyte** %argv) {
       %malloc_206 = malloc [10 x ubyte]
       %malloc_206.sub = getelementptr [10 x ubyte]* %malloc_206, int 0, int 0
       free ubyte* %malloc_206.sub
       ret int 0

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list