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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to