freebsd-dev/contrib/llvm-project
Dimitry Andric 8f6d9a8e68 Merge commit 41449c58c from llvm git (by Roger Ferrer Ibanez):
[RISCV] Fix evaluation of %pcrel_lo

  The following testcase

    function:
    .Lpcrel_label1:
          auipc   a0, %pcrel_hi(other_function)
          addi    a1, a0, %pcrel_lo(.Lpcrel_label1)
          .p2align        2          # Causes a new fragment to be emitted

          .type   other_function,@function
    other_function:
          ret

  exposes an odd behaviour in which only the %pcrel_hi relocation is
  evaluated but not the %pcrel_lo.

    $ llvm-mc -triple riscv64 -filetype obj t.s | llvm-objdump  -d -r -

    <stdin>:      file format ELF64-riscv

    Disassembly of section .text:
    0000000000000000 function:
           0:     17 05 00 00     auipc   a0, 0
           4:     93 05 05 00     mv      a1, a0
                  0000000000000004:  R_RISCV_PCREL_LO12_I other_function+4

    0000000000000008 other_function:
           8:     67 80 00 00     ret

  The reason seems to be that in RISCVAsmBackend::shouldForceRelocation
  we only consider the fragment but in RISCVMCExpr::evaluatePCRelLo we
  consider the section. This usually works but there are cases where
  the section may still be the same but the fragment may be another
  one. In that case we end forcing a %pcrel_lo relocation without any
  %pcrel_hi.

  This patch makes RISCVAsmBackend::shouldForceRelocation use the
  section, if any, to determine if the relocation must be forced or
  not.

  Differential Revision: https://reviews.llvm.org/D60657

This is a prerequisite for building and linking hard- and soft-float
riscv worlds with clang and lld.

Requested by:	jhb
MFC after:	1 week
X-MFC-With:	r353358
2020-01-03 20:09:38 +00:00
..
clang [PowerPC64] Starting from FreeBSD 13.0, default to ELFv2 ABI 2019-12-27 04:00:04 +00:00
compiler-rt [PowerPC] enable atomic.c in compiler_rt and do not check and forces 2019-12-26 23:06:28 +00:00
libcxx Merge commit f97936fab from llvm git (by Eric Fiselier): 2019-12-22 11:58:44 +00:00
libunwind Consolidate FREEBSD-Xlist files of different llvm sub-projects into one. 2019-12-20 21:42:10 +00:00
lld Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp 2019-12-22 11:50:44 +00:00
lldb Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp 2019-12-22 11:50:44 +00:00
llvm Merge commit 41449c58c from llvm git (by Roger Ferrer Ibanez): 2020-01-03 20:09:38 +00:00
openmp Consolidate FREEBSD-Xlist files of different llvm sub-projects into one. 2019-12-20 21:42:10 +00:00
FREEBSD-Xlist Consolidate FREEBSD-Xlist files of different llvm sub-projects into one. 2019-12-20 21:42:10 +00:00