[LLVMbugs] [Bug 20286] New: struct members not left-justified in function arguments on MIPS64

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 11 15:04:38 PDT 2014


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

            Bug ID: 20286
           Summary: struct members not left-justified in function
                    arguments on MIPS64
           Product: clang
           Version: trunk
          Hardware: SGI
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: msebor at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The MIPS64 ABI specifies in section n32 and Native 64-Bit (n64) Subprogram
Interface for MIPS Architectures that struct arguments are left justified. The
test case below shows that while GCC follows the ABI requirement (note the dsll
and dsra instructions in bar and foo, respectively, Clang does not.
$ cat t.c && clang -O2 -S --target=mips64 -mabi=n32 t.c && cat t.s &&
gcc.c4.7.0-p1.mips64-linux -O2 -S -mabi=n32 t.c && cat t.s
struct S { int i; };

__attribute__ ((noinline)) int foo (struct S s) { return s.i; }

int bar (void) { return foo ((struct S){ 1234 }); }

    .text
    .abicalls
    .option    pic0
    .section    .mdebug.abiN32,"", at progbits
    .nan    legacy
    .file    "t.c"
    .text
    .globl    foo
    .align    3
    .type    foo, at function
    .set    nomicromips
    .set    nomips16
    .ent    foo
foo:
    .frame    $fp,16,$ra
    .mask     0x00000000,0
    .fmask    0x40000000,-4
    .set    noreorder
    .set    nomacro
    .set    noat
    addiu    $sp, $sp, -16
    sd    $fp, 8($sp)
    move     $fp, $sp
    move     $2, $4
    move     $sp, $fp
    ld    $fp, 8($sp)
    jr    $ra
    addiu    $sp, $sp, 16
    .set    at
    .set    macro
    .set    reorder
    .end    foo
$tmp0:
    .size    foo, ($tmp0)-foo

    .globl    bar
    .align    3
    .type    bar, at function
    .set    nomicromips
    .set    nomips16
    .ent    bar
bar:
    .frame    $fp,16,$ra
    .mask     0x00000000,0
    .fmask    0xc0000000,-4
    .set    noreorder
    .set    nomacro
    .set    noat
    addiu    $sp, $sp, -16
    sd    $ra, 8($sp)
    sd    $fp, 0($sp)
    move     $fp, $sp
    jal    foo
    addiu    $4, $zero, 1234
    move     $sp, $fp
    ld    $fp, 0($sp)
    ld    $ra, 8($sp)
    jr    $ra
    addiu    $sp, $sp, 16
    .set    at
    .set    macro
    .set    reorder
    .end    bar
$tmp1:
    .size    bar, ($tmp1)-bar


    .ident    "clang version 3.5.0 (http://llvm.org/git/clang.git
90a108e0ebda1f9a61be251e693bf8b28d9b5dba) (http://llvm.org/git/llvm.git
013321a0f9e9f784ebb9a78ebf19e5f5099d5b16)"
    .file    1 "t.c"
    .section .mdebug.abiN32
    .previous
    .gnu_attribute 4, 3
    .abicalls
    .text
    .align    2
    .align    3
    .globl    foo
    .set    nomips16
    .ent    foo
    .type    foo, @function
foo:
    .frame    $sp,16,$31        # vars= 16, regs= 0/0, args= 0, gp= 0
    .mask    0x00000000,0
    .fmask    0x00000000,0
    .set    noreorder
    .set    nomacro
    addiu    $sp,$sp,-16
    dsra    $2,$4,32
    j    $31
    addiu    $sp,$sp,16

    .set    macro
    .set    reorder
    .end    foo
    .size    foo, .-foo
    .align    2
    .align    3
    .globl    bar
    .set    nomips16
    .ent    bar
    .type    bar, @function
bar:
    .frame    $sp,16,$31        # vars= 0, regs= 1/0, args= 0, gp= 0
    .mask    0x80000000,-8
    .fmask    0x00000000,0
    .set    noreorder
    .set    nomacro
    li    $4,1234            # 0x4d2
    addiu    $sp,$sp,-16
    sd    $31,8($sp)
    .option    pic0
    jal    foo
    .option    pic2
    dsll    $4,$4,32

    ld    $31,8($sp)
    j    $31
    addiu    $sp,$sp,16

    .set    macro
    .set    reorder
    .end    bar
    .size    bar, .-bar

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140711/f45b582f/attachment.html>


More information about the llvm-bugs mailing list