Skip to content

Commit 54248d5

Browse files
committed
Remove some more repetition
1 parent 3a73d1c commit 54248d5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7508,8 +7508,9 @@ SDValue RISCVTargetLowering::lowerINIT_TRAMPOLINE(SDValue Op,
75087508

75097509
// Store the given static chain and function pointer in the trampoline buffer.
75107510
struct OffsetValuePair {
7511-
unsigned Offset;
7512-
SDValue Value;
7511+
const unsigned Offset;
7512+
const SDValue Value;
7513+
SDValue Addr = SDValue(); // Used to cache the address.
75137514
} OffsetValues[] = {
75147515
{StaticChainOffset, StaticChain},
75157516
{FunctionAddressOffset, FunctionAddress},
@@ -7518,17 +7519,17 @@ SDValue RISCVTargetLowering::lowerINIT_TRAMPOLINE(SDValue Op,
75187519
SDValue Addr =
75197520
DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp,
75207521
DAG.getConstant(OffsetValue.Offset, dl, MVT::i64));
7522+
OffsetValue.Addr = Addr;
75217523
OutChains[Idx + 4] =
75227524
DAG.getStore(Root, dl, OffsetValue.Value, Addr,
75237525
MachinePointerInfo(TrmpAddr, OffsetValue.Offset));
75247526
}
75257527

75267528
SDValue StoreToken = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, OutChains);
75277529

7528-
// Compute end of instructions of trampoline.
7529-
SDValue EndOfTrmp =
7530-
DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp,
7531-
DAG.getConstant(StaticChainOffset, dl, MVT::i64));
7530+
// The end of instructions of trampoline is the same as the static chain
7531+
// address that we computed earlier.
7532+
SDValue EndOfTrmp = OffsetValues[0].Addr;
75327533

75337534
// Call clear cache on the trampoline instructions.
75347535
SDValue Chain = DAG.getNode(ISD::CLEAR_CACHE, dl, MVT::Other, StoreToken,

0 commit comments

Comments
 (0)