[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


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

             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
testcase

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
@_ZN5boost9date_time37time_resolution_traits_adapted64_impl9as_numberENS0_11int_adapterIxEE(%"class.boost::date_time::int_adapter"*
byval align 4 %i) align 2 {
entry:
  call void @emscripten_autodebug_i32(i32 -1, i32 61062)
  %call = call i64
@_ZNK5boost9date_time11int_adapterIxE9as_numberEv(%"class.boost::date_time::int_adapter"*
%i)
  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
@_ZN5boost9date_time37time_resolution_traits_adapted64_impl9as_numberENS0_11int_adapterIxEE(i64
%i.0) nounwind align 2 {
entry:
  %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
@_ZNK5boost9date_time11int_adapterIxE9as_numberEv(%"class.boost::date_time::int_adapter"*
%i)
  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
https://github.com/kripken/emscripten/issues/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