[LLVMdev] [ARM] [PIC] optimizing the loading of hidden global variable
Weiming Zhao
weimingz at codeaurora.org
Fri Mar 14 14:16:09 PDT 2014
I just gave a try to MegeGlobal with alias because I thought it's easy to do. However, another issue with it is:
Although I got aliases like:
@h0 = alias getelementptr inbounds (... at _MergedGlobals, 0, 0)
@h1 = alias getelementptr inbounds (... at _MergedGlobals, 0, 1)
@h2 = alias getelementptr inbounds (... at _MergedGlobals, 0, 2)
They cannot be lowered to correct asm. The all be aliases of _MergedGlobals:
.globl h0
.set h0, _MergedGlobals
.globl h1
.set h1, _MergedGlobals
.globl h2
.set h2, _MergedGlobals
I guess there is no support in asm to alias to a member of struct, right?
Thanks,
Weiming
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
-----Original Message-----
From: Rafael EspĂndola [mailto:rafael.espindola at gmail.com]
Sent: Friday, March 14, 2014 1:49 PM
To: Weiming Zhao
Cc: Tim Northover; LLVM Developers Mailing List; Jim Grosbach; Nick Kledzik
Subject: Re: [LLVMdev] [ARM] [PIC] optimizing the loading of hidden global variable
On 14 March 2014 14:34, Weiming Zhao <weimingz at codeaurora.org> wrote:
> Hi Rafael,
>
> Yes, merging gv prevents linker to do garbage collection. Should it be implemented as a peephole pass? If we do it too early, the distance between GVs are not fixed yet.
Correct. It would be somewhere in CodeGen, I am not exactly sure where.
> PS:
> Below is the GCC output with "extern" hidden:
> ldr r2, .L2
> stmfd sp!, {r3, lr}
> .save {r3, lr}
> .LPIC0:
> add r0, pc, r2
> bl _Z4initPv(PLT)
> ldr r1, .L2+4
> .LPIC1:
> add r0, pc, r1
> bl _Z4initPv(PLT)
> ldr r0, .L2+8
> .LPIC2:
> add r0, pc, r0
> ldmfd sp!, {r3, lr}
> b _Z4initPv(PLT)
> .L3:
> .align 2
> .L2:
> .word g0-(.LPIC0+8)
> .word g1-(.LPIC1+8)
> .word g2-(.LPIC2+8)
That is pretty neat too.
Cheers,
Rafael
More information about the llvm-dev
mailing list