[llvm] r211040 - Fix illegal relocations in X86FastISel

Eric Christopher echristo at gmail.com
Mon Jun 16 10:52:09 PDT 2014


On Mon, Jun 16, 2014 at 10:35 AM, Louis Gerbarg <lgg at apple.com> wrote:
> Author: louis
> Date: Mon Jun 16 12:35:40 2014
> New Revision: 211040
>
> URL: http://llvm.org/viewvc/llvm-project?rev=211040&view=rev
> Log:
> Fix illegal relocations in X86FastISel
>
> On x86_86  the lea instruction can only use a 32 bit immediate value. When
> the code is compiled statically the RIP register is not used, meaning the
> immediate is all that can be used for the relocation, which is not sufficient
> in the case of targets more than +/- 2GB away. This patch bails out of fast
> isel in those cases and reverts to DAG which does the right thing.
>
> Test case included.

Some questions below:

>    // Materialize addresses with LEA instructions.
>    if (isa<GlobalValue>(C)) {
> +    //LEA can only handle 32 bit immediates
> +    if (TM.getRelocationModel() == Reloc::Static && Subtarget->is64Bit())
> +      return false;
> +
>

Couldn't we lock down this check a bit more or handle the case?

> ==============================================================================
> --- llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll (original)
> +++ llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll Mon Jun 16 12:35:40 2014
> @@ -10,10 +10,10 @@
>  ; with "clang++ -S -emit-llvm -fsanitize=address -O0 -g test.cc"
>
>  ; First, argument variable "y" resides in %rdi:
> -; CHECK: DEBUG_VALUE: bar:y <- RDI
> +; CHECK: DEBUG_VALUE: bar:y <- RDX
>

The comment says rdi, the code says rdx. :)

Did you verify it's actually in rdx now? If so, could you update it.

-eric

>  ; Then its address is stored in a location on a stack:
> -; CHECK: movq %rdi, [[OFFSET:[0-9]+]](%rsp)
> +; CHECK: movq %rdx, [[OFFSET:[0-9]+]](%rsp)
>  ; CHECK-NEXT: [[START_LABEL:.Ltmp[0-9]+]]
>  ; CHECK-NEXT: DEBUG_VALUE: bar:y <- [RSP+[[OFFSET]]]
>  ; This location should be valid until the end of the function.
> @@ -26,7 +26,7 @@
>  ; CHECK-NEXT: .quad .Lset{{[0-9]+}}
>  ; CHECK-NEXT: .Lset{{[0-9]+}} = [[START_LABEL]]-.Lfunc_begin0
>  ; CHECK-NEXT: .quad .Lset{{[0-9]+}}
> -; CHECK: DW_OP_reg5
> +; CHECK: DW_OP_reg1
>
>  ; Then it's addressed via %rsp:
>  ; CHECK:      .Lset{{[0-9]+}} = [[START_LABEL]]-.Lfunc_begin0
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list