[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


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

           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}};
    f(x);
}

-----------------------------------------------------------------------------

$clang bug.c -S -emit-llvm -o - -O3
; ModuleID = 'bug.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-pc-linux-gnu"

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

define void @g() nounwind {
entry:
  %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