[LLVMbugs] [Bug 3474] New: x86-32: clang could avoid byval in more cases

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Feb 3 10:59:35 PST 2009


           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: unassignedclangbugs at nondot.org
        ReportedBy: daniel at zuster.org
                CC: llvmbugs at cs.uiuc.edu

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

define i64 @f0(%struct.s* byval %x) nounwind {
        %retval = alloca %struct.s              ; <%struct.s*> [#uses=2]
        %tmp = bitcast %struct.s* %retval to i8*                ; <i8*>
        %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

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