[LLVMbugs] [Bug 15822] New: DeadStoreElimination ("-dse") eliminates a store that isn't dead

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 22 15:15:08 PDT 2013


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

            Bug ID: 15822
           Summary: DeadStoreElimination ("-dse") eliminates a store that
                    isn't dead
           Product: tools
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: mseaborn at chromium.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

DeadStoreElimination ("-dse") eliminates a store that isn't dead.

In the following test case, which is a reduced version of
SingleSource/UnitTests/byval-alignment.c from the LLVM test suite, @do_copy()
should set @g0 to 1234:


@g0 = global i32 zeroinitializer, align 4
@init_val = global i32 1234, align 4

declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32,
i1)

define void @f0(i8* %y) noinline {
  tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* bitcast (i32* @g0 to i8*), i8*
%y, i32 4, i32 1, i1 false)
  ret void
}

define void @do_copy() {
  %copy = alloca i32, align 4
  %copy_cast = bitcast i32* %copy to i8*
  %init_val_cast = bitcast i32* @init_val to i8*
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %copy_cast, i8* %init_val_cast, i32
4, i32 1, i1 false)
  tail call void @f0(i8* %copy_cast)
  ret void
}


However, "-dse" removes the memcpy() from @do_copy so that it will copy
uninitialised data to @g0:

$ opt -basicaa -dse byval-min.ll -S -o -
...
define void @do_copy() {
  %copy = alloca i32, align 4
  %copy_cast = bitcast i32* %copy to i8*
  tail call void @f0(i8* %copy_cast)
  ret void
}

This also occurs with "opt -std-link-opts".

This occurs in at least LLVM 3.0, 3.1 and r176253.

-- 
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/20130422/807c45ff/attachment.html>


More information about the llvm-bugs mailing list