[LLVMbugs] [Bug 17727] New: clang should throw away unused assignment before operator delete

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Oct 29 10:27:16 PDT 2013


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

            Bug ID: 17727
           Summary: clang should throw away unused assignment before
                    operator delete
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yozh at mx1.ru
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Code:

===
void foo(int* x) {
    x[0] = 54321;
    delete[] x;
}
===

When compiled with clang++ -O3 -c -S -emit-llvm, produces bitcode:

===
define void @_Z3fooPi(i32* %x) #0 {
  store i32 54321, i32* %x, align 4, !tbaa !0
  %1 = icmp eq i32* %x, null
  br i1 %1, label %4, label %2

; <label>:2                                       ; preds = %0
  %3 = bitcast i32* %x to i8*
  tail call void @_ZdaPv(i8* %3) #2
  br label %4

; <label>:4                                       ; preds = %2, %0
  ret void
}
===

`store i32 54321 ...` can be thrown away. clang already does it if `free`
function is used instead of operator delete.

-- 
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/20131029/9b144906/attachment.html>


More information about the llvm-bugs mailing list