[LLVMbugs] [Bug 12537] New: byval optimization forgets necessary copy

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 12 10:40:54 PDT 2012


             Bug #: 12537
           Summary: byval optimization forgets necessary copy
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: opt
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: alonzakai at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 8377
  --> http://llvm.org/bugs/attachment.cgi?id=8377

Steps to reproduce:

1. Run opt -O1 --disable-inlining on the attachment
2. Compare to the original before optimization

The unoptimized code for the crucial function is

define linkonce_odr i64
byval align 4 %i) align 2 {
  call void @emscripten_autodebug_i32(i32 -1, i32 61062)
  %call = call i64
  call void @emscripten_autodebug_i64(i32 61062, i64 %call)
  call void @emscripten_autodebug_i32(i32 -2, i32 61065)
  ret i64 %call

and the optimized version is

define internal fastcc i64
%i.0) nounwind align 2 {
  %i = alloca %"class.boost::date_time::int_adapter", align 8
  tail call fastcc void @emscripten_autodebug_i32(i32 -1, i32 61062)
  %call = tail call fastcc i64
  tail call fastcc void @emscripten_autodebug_i64(i32 61062, i64 %call)
  tail call fastcc void @emscripten_autodebug_i32(i32 -2, i32 61065)
  ret i64 %call

In the unoptimized one it uses byval so a copy is created of the %i that is
received. In the optimized one, it creates space on the stack for the copy -
but doesn't actually copy. So it uses uninitialized stack data and %i.0 which
it receives, is ignored.

Background is Emscripten issue 376

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list