https://llvm.org/bugs/show_bug.cgi?id=31228

            Bug ID: 31228
           Summary: Rematerial address for literal string pool
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: weimi...@codeaurora.org
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

given test.c:

extern void mylog(const char*);
#define LOG(msg) {  static const char __attribute__((section("logstrings")))
mystring[] = #msg; mylog(mystring); }


void test() {
  LOG("this is log msg 0");
  LOG("this is log msg 11");
  LOG("this is log msg 222");
  LOG("this is log msg 3333");
}

The code puts all string literals in the same section. GCC is able to
rematerial the address:
arm-linux-gnueabi-gcc -mcpu=cortex-m3 -Os

    push    {r4, lr}
    ldr    r4, .L2
    mov    r0, r4
    bl    mylog
    add    r0, r4, #20
    bl    mylog
    add    r0, r4, #40
    bl    mylog
    add    r0, r4, #60
    pop    {r4, lr}
    b    mylog


but LLVM generates larger code:

clang -mcpu=cortex-m3 -target armv7m-linux-gnueabi -c -Os 

    push    {r7, lr}
    .setfp    r7, sp
    mov    r7, sp
    movw    r0, :lower16:test.mystring
    movt    r0, :upper16:test.mystring
    bl    mylog
    movw    r0, :lower16:test.mystring.1
    movt    r0, :upper16:test.mystring.1
    bl    mylog
    movw    r0, :lower16:test.mystring.2
    movt    r0, :upper16:test.mystring.2
    bl    mylog
    movw    r0, :lower16:test.mystring.3
    movt    r0, :upper16:test.mystring.3
    pop.w    {r7, lr}
    b    mylog

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to