[LLVMdev] Best way to clean up empty global_ctors

Nico Weber
2014-05-01T18:16:27Z

On Thu, May 1, 2014 at 11:12 AM, Rafael Espíndola
<rafael.espindola at gmail.com> wrote:
> On 1 May 2014 14:08, Reid Kleckner <rnk at google.com> wrote:
>> I talked about this with Nick in person months ago, and my
understanding is
>> that GlobalOpt is also an enabling optimization that needs to run
early.
>> For example, if we can eliminate an initializer to an internal global
with
>> no other stores to it, we can propagate the result.
>>
>> Maybe we should run it twice.
>
> That is probably fine, we just have to make sure compile time doesn't
> surfer too much.

Looking at GlobalOpt, it seems to do full symbolic evaluation of all
constructors, which is more than what's needed here. Just walking
llvm.global_ctors and removing calls to functions that are just "ret"
is all that's needed. Unless folks think that's a terrible idea,
I'll
try to write a lightweight pass for doing just that.