Skip to content

Commit

Permalink
[RISCV] Fix buildbot breakage by explicitly instantiating templates
Browse files Browse the repository at this point in the history
RISCVISelDAGToDAG's selectImm uses RISCVTargetLowering::getAddr
(specifically the ConstantPoolSDNode) as of 41454ab ("[RISCV] Use
constant pool for large integers"), but nothing explicitly instantiates
any of the templates, the only reason they exist is because of the
various lowering methods in RISCVISelLowering.cpp that themselves use
the methods. However, with inlining, those can end up not existing as
real functions and thus not be exported, leading to link errors. Up
until now this hasn't happened, but for whatever reason D121654 has
triggered this on the sanitizer-ppc64be-linux buildbot, giving:

  ../../../../lib/libLLVMRISCVCodeGen.a(RISCVISelDAGToDAG.cpp.o): In function `selectImm(llvm::SelectionDAG*, llvm::SDLoc const&, llvm::MVT, long, llvm::RISCVSubtarget const&)':
  RISCVISelDAGToDAG.cpp:(.text._ZL9selectImmPN4llvm12SelectionDAGERKNS_5SDLocENS_3MVTElRKNS_14RISCVSubtargetE+0x3d8): undefined reference to `llvm::SDValue llvm::RISCVTargetLowering::getAddr<llvm::ConstantPoolSDNode>(llvm::ConstantPoolSDNode*, llvm::SelectionDAG&, bool) const'
  collect2: error: ld returned 1 exit status

Fix this by explicitly instantiating getAddr in its four different forms
so separate translation units can reliably use it.

Fixes: 41454ab ("[RISCV] Use constant pool for large integers")
  • Loading branch information
jrtc27 committed Mar 18, 2022
1 parent 9065dd1 commit 63ea779
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Expand Up @@ -3769,6 +3769,15 @@ SDValue RISCVTargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG,
}
}

template SDValue RISCVTargetLowering::getAddr<GlobalAddressSDNode>(
GlobalAddressSDNode *N, SelectionDAG &DAG, bool IsLocal) const;
template SDValue RISCVTargetLowering::getAddr<BlockAddressSDNode>(
BlockAddressSDNode *N, SelectionDAG &DAG, bool IsLocal) const;
template SDValue RISCVTargetLowering::getAddr<ConstantPoolSDNode>(
ConstantPoolSDNode *N, SelectionDAG &DAG, bool IsLocal) const;
template SDValue RISCVTargetLowering::getAddr<JumpTableSDNode>(
JumpTableSDNode *N, SelectionDAG &DAG, bool IsLocal) const;

SDValue RISCVTargetLowering::lowerGlobalAddress(SDValue Op,
SelectionDAG &DAG) const {
SDLoc DL(Op);
Expand Down

0 comments on commit 63ea779

Please sign in to comment.