[llvm] r208934 - Implement global merge optimization for global variables.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jun 3 07:16:25 PDT 2014


> (1) We probably should change the global merge algorithm by considering the
> global symbols function by function, which could finally benefit linker to
> remove dead global symbols. I think I agree with that, but I want to leave
> it for further improvement in future, so I added a FIXME in my new patch to
> explain the issue.

OK.

> (2) We should avoid adding target dependent interfaces in middle-end, so it
> would be better we don't add getGlobalMergeAlignment. I consider it again,
> and think we still need this, and it is orthogonal with (1). For AArch64, we
> need this because we want to make sure the merged global variable doesn't
> cross page boundary, and this could finally remove one more "addition"
> instruction finally.

But there is nothing special about a merge variable, right?  Consider
two cases. In the first, the source code has a user defined type and
global:

struct foo {
  int a;
   int b;
} my_global;

int the second case the globals are just "int a;" and "int b;". In the
second case we decide to concatenate 'a' and 'b'. Any alignment
advantage that can be had in the second case also applies to the
first, so it seems this should just be an independent optimization in
the aarch64 backend.

A related issue is that we probably don't want to have codegen options
like global-merge-aligned.

Cheers,
Rafael



More information about the llvm-commits mailing list