[ARM] Promote small global constants to constant pools
commit2e1f8100c53e0c6fd2b923136dafbfb12a83cf91
authorJames Molloy <james.molloy@arm.com>
Tue, 13 Sep 2016 10:28:11 +0000 (13 10:28 +0000)
committerJames Molloy <james.molloy@arm.com>
Tue, 13 Sep 2016 10:28:11 +0000 (13 10:28 +0000)
treefda26fba273dbd61c9bb8ec0ce720d3a85be2b03
parentea8e2d383d57c65fd977bb840ce819b000e87dc5
[ARM] Promote small global constants to constant pools

If a constant is unamed_addr and is only used within one function, we can save
on the code size and runtime cost of an indirection by changing the global's storage
to inside the constant pool. For example, instead of:

      ldr r0, .CPI0
      bl printf
      bx lr
    .CPI0: &format_string
    format_string: .asciz "hello, world!\n"

We can emit:

      adr r0, .CPI0
      bl printf
      bx lr
    .CPI0: .asciz "hello, world!\n"

This can cause significant code size savings when many small strings are used in one
function (4 bytes per string).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281314 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/ARM/ARMAsmPrinter.h
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMMachineFunctionInfo.h
test/CodeGen/ARM/constantpool-promote.ll [new file with mode: 0644]