[LLVMbugs] [Bug 6798] New: missed optimization on byval argument with memcpy

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Apr 6 12:12:59 PDT 2010


           Summary: missed optimization on byval argument with memcpy
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: quickslyver at free.fr
                CC: llvmbugs at cs.uiuc.edu

in the generated code bellow, I think the memcpy is useless because the
argument of the function f is passed "byval"

$ cat bug.c
struct a { int v[500];};
int f(struct a);

void g()
    struct a x={{0,1,2,3,4,5}};


$clang bug.c -S -emit-llvm -o - -O3
; ModuleID = 'bug.c'
target datalayout =
target triple = "i386-pc-linux-gnu"

@g.x = internal constant %struct.a { 

define void @g() nounwind {
  %agg.tmp = alloca %struct.a, align 4            ; <%struct.a*> [#uses=2]
  %agg.tmp.04 = bitcast %struct.a* %agg.tmp to i8* ; <i8*> [#uses=1]
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %agg.tmp.04, i8* bitcast (%struct.a*
@g.x to i8*), i32 2000, i32 4, i1 false)
  %call = call i32 @f(%struct.a* byval %agg.tmp) nounwind ; <i32> [#uses=0]
  ret void

declare i32 @f(%struct.a* byval)

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