[llvm-bugs] [Bug 31228] New: Rematerial address for literal string pool

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 1 12:15:07 PST 2016


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: unassignedbugs at nondot.org
          Reporter: weimingz at codeaurora.org
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161201/93279f79/attachment.html>


More information about the llvm-bugs mailing list