[LLVMbugs] [Bug 6573] New: msp430 backend: arguments passed in wrong registers

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 10 10:34:00 PST 2010


           Summary: msp430 backend: arguments passed in wrong registers
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: pagariya at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu, regehr at cs.utah.edu

Test case:

#include <stdint.h>

int8_t g_8[6][10];

int main(void)
    int i, j;
    for (i = 0; i < 6; i++)
        for (j = 0; j < 10; j++)
            g_8[i][j] = 0x44L;
    return 0;

In the above code g_8 is an array of 6x10 bytes, which is initialized to 0x44.
At -O2 and -O3, this array is initialized using memset().

C interface to memset(): void* memset(void* ptr, int value, size_t num);
Asm interface to memset(): ptr -> reg r15
                           data -> reg r14
                           size -> reg r13

Assembly code at -O2 and -O3 for call to memset():

mov.w #0, r11
mov.w r11, r15
add.w #g_8, r15
mov.w #68, r14
mov.w #0, r13   /* size expected here, passed 0 */
mov.w #10, r12  /* Size passed in r12, ignored */
call  #memset
add.w #10, r11
cmp.w #60, r11
jne .LBB1_1
mov.w #0, r15

Bug: size argument to memset() should be passed in register r13. Instead it is
passed in r12.

I am attaching the asm file at -O2. Below are the cmdline options.

pagariya at aleph:~/randprog-testing/main/tmp$ clang -ccc-host-triple msp430-elf
-I/home/pagariya/res-pagariya/llvm-msp430/msp430/include -nostdinc -v -O2 -S
clang version 1.1 (trunk 184)
Target: msp430-elf-
Thread model: posix
 "/uusoc/facility/res/embed/users/pagariya/llvm-msp430/bin/clang" -cc1 -triple
msp430-elf- -S -disable-free -main-file-name test.c -mrelocation-model static
-mdisable-fp-elim -mconstructor-aliases -v -nostdinc -resource-dir
-I/home/pagariya/res-pagariya/llvm-msp430/msp430/include -O2 -fmessage-length
102 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o test.s -x c
clang -cc1 version 1.1 based upon llvm 2.7svn hosted on i386-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
End of search list.

pagariya at aleph:~/randprog-testing/main/tmp$ uname -a
Linux aleph 2.6.24-24-generic #1 SMP Fri Sep 18 16:49:39 UTC 2009 i686

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