[llvm-commits] [PATCH][RFC] PR10367: don't allow GlobalAlias's aliasee to be an arbitrary Constant

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Sat Jul 30 08:28:37 PDT 2011


> Ciao, Duncan.
> 
> [*] The simplest and most useful case is a GEP with all constant integer
> operands that is just referring to some field inside the global.  I have
> no idea if ELF supports that, but probably by outputting a label before
> each field of the global and having the alias-GEP turn into an alias of the
> appropriate label you could get the desired effect.

Yes, for example, it would be reasonable to compile

const int a = 43;
const int b[2] = {42, 43};

to something like

	.section	.rodata

        .globl a
	.type	a, @object
	.size	a, 4

        .globl b
	.type	b, @object
	.size	b, 8

	.align 8
b:
	.long	42
a:
	.long	43


Cheers,
Rafael



More information about the llvm-commits mailing list