[RISCV] Lower extern_weak symbols using the GOT for the medany model
authorJessica Clarke <jrtc27@jrtc27.com>
Wed, 31 May 2023 17:30:36 +0000 (18:30 +0100)
committerJessica Clarke <jrtc27@jrtc27.com>
Wed, 31 May 2023 17:48:21 +0000 (18:48 +0100)
commita178ba9fbd0a27057dc2fa4cb53c76caa013caac
tree93014cd2f6ad5c01163f884ce875f4a9191029dd
parent9b55e5d42067c26c633298bbaca0c2802afe95ed
[RISCV] Lower extern_weak symbols using the GOT for the medany model

Such symbols may be undefined at link time and thus resolve to 0, which
may be further than 2GiB away from PC, causing the immediate to be out
of range for PC-relative addressing. Using the GOT avoids this, and is
the approach taken by AArch64.

Reviewed By: asb, MaskRay, arichardson

Differential Revision: https://reviews.llvm.org/D107280
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/test/CodeGen/RISCV/codemodel-lowering.ll