[LLVMbugs] [Bug 5824] New: clang codegen introduces extra struct copy calling function returning struct

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Dec 17 15:26:12 PST 2009


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

           Summary: clang codegen introduces extra struct copy calling
                    function returning struct
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


Testcase:
struct a { int a[10]; };
struct a a();
struct a b() { return a(); }

Output (clang -x c - -o - -S -emit-llvm):
define void @b(%struct.a* noalias sret %agg.result) nounwind {
entry:
  %tmp = alloca %struct.a                         ; <%struct.a*> [#uses=2]
  call void (%struct.a*, ...)* @a(%struct.a* noalias sret %tmp)
  %tmp1 = bitcast %struct.a* %agg.result to i8*   ; <i8*> [#uses=1]
  %tmp2 = bitcast %struct.a* %tmp to i8*          ; <i8*> [#uses=1]
  call void @llvm.memcpy.i32(i8* %tmp1, i8* %tmp2, i32 40, i32 4)
  ret void
}

The memcpy isn't necessary and shouldn't be there.  This affects correctness in
some edge cases in C++, and leads to inefficient code in other cases.


-- 
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