@@ -7223,8 +7223,9 @@ SDValue RISCVTargetLowering::lowerINIT_TRAMPOLINE(SDValue Op,
72237223
72247224 // Store the given static chain and function pointer in the trampoline buffer.
72257225 struct OffsetValuePair {
7226- unsigned Offset;
7227- SDValue Value;
7226+ const unsigned Offset;
7227+ const SDValue Value;
7228+ SDValue Addr = SDValue(); // Used to cache the address.
72287229 } OffsetValues[] = {
72297230 {StaticChainOffset, StaticChain},
72307231 {FunctionAddressOffset, FunctionAddress},
@@ -7233,17 +7234,17 @@ SDValue RISCVTargetLowering::lowerINIT_TRAMPOLINE(SDValue Op,
72337234 SDValue Addr =
72347235 DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp,
72357236 DAG.getConstant(OffsetValue.Offset, dl, MVT::i64));
7237+ OffsetValue.Addr = Addr;
72367238 OutChains[Idx + 4] =
72377239 DAG.getStore(Root, dl, OffsetValue.Value, Addr,
72387240 MachinePointerInfo(TrmpAddr, OffsetValue.Offset));
72397241 }
72407242
72417243 SDValue StoreToken = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, OutChains);
72427244
7243- // Compute end of instructions of trampoline.
7244- SDValue EndOfTrmp =
7245- DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp,
7246- DAG.getConstant(StaticChainOffset, dl, MVT::i64));
7245+ // The end of instructions of trampoline is the same as the static chain
7246+ // address that we computed earlier.
7247+ SDValue EndOfTrmp = OffsetValues[0].Addr;
72477248
72487249 // Call clear cache on the trampoline instructions.
72497250 SDValue Chain = DAG.getNode(ISD::CLEAR_CACHE, dl, MVT::Other, StoreToken,
0 commit comments