From 555df030121aeaaf33b1a89489960a77ef94d472 Mon Sep 17 00:00:00 2001 From: Marco Elver Date: Wed, 16 Mar 2022 17:35:10 +0100 Subject: [PATCH] [SelectionDAG][NFC] Clean up SDCallSiteDbgInfo accessors * Consistent naming: addCallSiteInfo vs. getCallSiteInfo; * Use ternary operator to reduce verbosity; * const'ify getters; * Add comments; NFCI. Differential Revision: https://reviews.llvm.org/D121820 --- llvm/include/llvm/CodeGen/SelectionDAG.h | 39 ++++++++----------- .../SelectionDAG/ScheduleDAGSDNodes.cpp | 2 +- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index 94efad8b7947..d42944cffd5d 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -2119,39 +2119,34 @@ public: isConstantFPBuildVectorOrConstantFP(N); } - void addCallSiteInfo(const SDNode *CallNode, CallSiteInfoImpl &&CallInfo) { - SDCallSiteDbgInfo[CallNode].CSInfo = std::move(CallInfo); + /// Set CallSiteInfo to be associated with Node. + void addCallSiteInfo(const SDNode *Node, CallSiteInfoImpl &&CallInfo) { + SDCallSiteDbgInfo[Node].CSInfo = std::move(CallInfo); } - - CallSiteInfo getSDCallSiteInfo(const SDNode *CallNode) { - auto I = SDCallSiteDbgInfo.find(CallNode); - if (I != SDCallSiteDbgInfo.end()) - return std::move(I->second).CSInfo; - return CallSiteInfo(); + /// Return CallSiteInfo associated with Node, or a default if none exists. + CallSiteInfo getCallSiteInfo(const SDNode *Node) { + auto I = SDCallSiteDbgInfo.find(Node); + return I != SDCallSiteDbgInfo.end() ? std::move(I->second).CSInfo + : CallSiteInfo(); } - + /// Set HeapAllocSite to be associated with Node. void addHeapAllocSite(const SDNode *Node, MDNode *MD) { SDCallSiteDbgInfo[Node].HeapAllocSite = MD; } - - /// Return the HeapAllocSite type associated with the SDNode, if it exists. - MDNode *getHeapAllocSite(const SDNode *Node) { - auto It = SDCallSiteDbgInfo.find(Node); - if (It == SDCallSiteDbgInfo.end()) - return nullptr; - return It->second.HeapAllocSite; + /// Return HeapAllocSite associated with Node, or nullptr if none exists. + MDNode *getHeapAllocSite(const SDNode *Node) const { + auto I = SDCallSiteDbgInfo.find(Node); + return I != SDCallSiteDbgInfo.end() ? I->second.HeapAllocSite : nullptr; } - + /// Set NoMergeSiteInfo to be associated with Node if NoMerge is true. void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge) { if (NoMerge) SDCallSiteDbgInfo[Node].NoMerge = NoMerge; } - - bool getNoMergeSiteInfo(const SDNode *Node) { + /// Return NoMerge info associated with Node. + bool getNoMergeSiteInfo(const SDNode *Node) const { auto I = SDCallSiteDbgInfo.find(Node); - if (I == SDCallSiteDbgInfo.end()) - return false; - return I->second.NoMerge; + return I != SDCallSiteDbgInfo.end() ? I->second.NoMerge : false; } /// Return the current function's default denormal handling kind for the given diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp index 55f6f288f3e3..d6a014ecbb6a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -883,7 +883,7 @@ EmitSchedule(MachineBasicBlock::iterator &InsertPos) { if (MI->isCandidateForCallSiteEntry() && DAG->getTarget().Options.EmitCallSiteInfo) - MF.addCallArgsForwardingRegs(MI, DAG->getSDCallSiteInfo(Node)); + MF.addCallArgsForwardingRegs(MI, DAG->getCallSiteInfo(Node)); if (DAG->getNoMergeSiteInfo(Node)) { MI->setFlag(MachineInstr::MIFlag::NoMerge);