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

           Summary: x86-32: clang could avoid byval in more cases
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


clang currently passes some structures byval even when they will be passed in
an integer register. clang should avoid using byval in such cases to give the
LLVM optimizers the most freedom to hack on the type.

For example,
--
ddun...@67-218-102-230:single-args$ cat t.c
struct s { short a, b, c, d; } f0(struct s x) {
  return x;
}
ddun...@67-218-102-230:single-args$ xcc -emit-llvm -S -o - t.c -m32
; ModuleID = 't.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:128:128"
target triple = "i386-apple-darwin10.0"
        %struct.s = type <{ i16, i16, i16, i16 }>

define i64 @f0(%struct.s* byval %x) nounwind {
entry:
        %retval = alloca %struct.s              ; <%struct.s*> [#uses=2]
        %tmp = bitcast %struct.s* %retval to i8*                ; <i8*>
[#uses=1]
        %tmp1 = bitcast %struct.s* %x to i8*            ; <i8*> [#uses=1]
        call void @llvm.memmove.i32(i8* %tmp, i8* %tmp1, i32 8, i32 2)
        %0 = bitcast %struct.s* %retval to i64*         ; <i64*> [#uses=1]
        %1 = load i64* %0               ; <i64> [#uses=1]
        ret i64 %1
}

declare void @llvm.memmove.i32(i8* nocapture, i8* nocapture, i32, i32) nounwind
--

This should be easy to fix since return arguments already get coerced to avoid
sret.


-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to