[llvm-commits] [PATCH] x86 code emitter improvements for object files

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Mon Aug 3 11:23:11 PDT 2009


Is it ok to commit this?

On Fri, Jul 31, 2009 at 8:03 PM, Bruno Cardoso
Lopes<bruno.cardoso at gmail.com> wrote:
> Hi all,
>
> The X86CodeEmitter has the following behaviour:
>
> 1) When emiting displacements:
> - Only use pc_relative relocations for x86_64 (globals, cstpools and jmptables)
> - For x86, only uses pc_rel ou pic_re
> This two items above do not always work for ELF.
>
> 2) RIP addressing:
> The way emitMemModRMByte works now uses RIP relocation for all cases
> where RegBase=0, IndexReg=0, and when the displacement needs relocation. And
> for those cases, it will never generate a SIB byte + absolute
> relocation, which ELF
> needs.
>
> 3) The JIT can get the real address of cstpools and jmptables during
> code emission,
> but the same won't work for relocatable object files.
>
> This patch try to solve the 3 problems above to properly emit elf
> binaries for x86/x86_64. With
> this changes applied (together with elf improvements I've not commited
> yet) I was able
> to run 209/243 (83%) of SinglesSources using ELF object files emited by LLC :)
> and with no regressions for JIT.
>
> The way the patch was done tries to ensure that no previous JIT code
> emission mechanism will
> be changed, trying to avoid loss in performance and new JIT bugs.
>
> The patch also introduces a new x86 relocation type reloc_absolute_word_sext,
> which is lowered to x86 elf reloc type R_X86_64_32S.
>
> Please, review and comment :)
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc
>



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc



More information about the llvm-commits mailing list