git: bf2378688d27 - releng/13.1 - Merge LLVM commit c03fdd340356 to fix lang/rust on powerpc

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Mon, 28 Mar 2022 14:15:59 UTC
The branch releng/13.1 has been updated by pkubaj (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=bf2378688d276903dc63437758af7962dad2ccd5

commit bf2378688d276903dc63437758af7962dad2ccd5
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2022-03-24 00:30:44 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2022-03-28 14:15:32 +0000

    Merge LLVM commit c03fdd340356 to fix lang/rust on powerpc
    
    Without it building rust fails with:
    ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0xB0): relocation R_PPC_PLTREL24 out of range: -33582208 is not in [-33554432, 33554431]
    
    Reviewed by:    dim
    Approved by:    re (gjb)
    Differential Revision: https://reviews.freebsd.org/D34652
    MFC after:      3 days
    
    (cherry picked from commit 9b597132aea7d75810ca90258022f81d07971444)
    (cherry picked from commit 56a4f560d429188625de4075983ec380bf8f7057)
---
 contrib/llvm-project/lld/ELF/Relocations.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/contrib/llvm-project/lld/ELF/Relocations.cpp b/contrib/llvm-project/lld/ELF/Relocations.cpp
index 537859f9e0b5..eb3d115266a6 100644
--- a/contrib/llvm-project/lld/ELF/Relocations.cpp
+++ b/contrib/llvm-project/lld/ELF/Relocations.cpp
@@ -1966,7 +1966,8 @@ std::pair<Thunk *, bool> ThunkCreator::getThunk(InputSection *isec,
   // out in the relocation addend. We compensate for the PC bias so that
   // an Arm and Thumb relocation to the same destination get the same keyAddend,
   // which is usually 0.
-  int64_t keyAddend = rel.addend + getPCBias(rel.type);
+  const int64_t pcBias = getPCBias(rel.type);
+  const int64_t keyAddend = rel.addend + pcBias;
 
   // We use a ((section, offset), addend) pair to find the thunk position if
   // possible so that we create only one thunk for aliased symbols or ICFed
@@ -1985,7 +1986,7 @@ std::pair<Thunk *, bool> ThunkCreator::getThunk(InputSection *isec,
     if (isThunkSectionCompatible(isec, t->getThunkTargetSym()->section) &&
         t->isCompatibleWith(*isec, rel) &&
         target->inBranchRange(rel.type, src,
-                              t->getThunkTargetSym()->getVA(rel.addend)))
+                              t->getThunkTargetSym()->getVA(-pcBias)))
       return std::make_pair(t, false);
 
   // No existing compatible Thunk in range, create a new one