<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Renamed in r316341. Took a few days because I was busy recovering from the dev meeting.<div class=""><br class=""></div><div class="">endIdx -> getEndIdx</div><div class="">length -> getLength</div><div class="">startIdx -> getStartIdx<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 17, 2017, at 6:01 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" class="">chisophugis@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">LLVM typically prefers "getFoo" type names for getters. More broadly the rule is verb phrases: <a href="https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly" class="">https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly</a><div class=""><br class=""></div><div class="">The main exception I can think of is when we are trying to be compatible with STL conventions. E.g. Value::{use_begin,use_end,users}<br class=""><div class=""><br class=""></div><div class="">-- Sean Silva</div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Oct 17, 2017 at 11:43 AM, Jessica Paquette via llvm-commits <span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: paquette<br class="">
Date: Tue Oct 17 11:43:15 2017<br class="">
New Revision: 316019<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=316019&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project?rev=316019&view=rev</a><br class="">
Log:<br class="">
[MachineOutliner][NFC] Move end index calculation into Candidate<br class="">
<br class="">
Cleanup to Candidate that moves all end index calculations into<br class="">
Candidate.endIdx(). For the sake of consistency, StartIdx and Len are now<br class="">
private members, and can be accessed with length() and startIdx() respectively.<br class="">
<br class="">
<br class="">
Modified:<br class="">
llvm/trunk/lib/CodeGen/<wbr class="">MachineOutliner.cpp<br class="">
<br class="">
Modified: llvm/trunk/lib/CodeGen/<wbr class="">MachineOutliner.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOutliner.cpp?rev=316019&r1=316018&r2=316019&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/llvm/trunk/lib/<wbr class="">CodeGen/MachineOutliner.cpp?<wbr class="">rev=316019&r1=316018&r2=<wbr class="">316019&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- llvm/trunk/lib/CodeGen/<wbr class="">MachineOutliner.cpp (original)<br class="">
+++ llvm/trunk/lib/CodeGen/<wbr class="">MachineOutliner.cpp Tue Oct 17 11:43:15 2017<br class="">
@@ -92,23 +92,33 @@ namespace {<br class="">
/// \brief An individual sequence of instructions to be replaced with a call to<br class="">
/// an outlined function.<br class="">
struct Candidate {<br class="">
-<br class="">
- /// Set to false if the candidate overlapped with another candidate.<br class="">
- bool InCandidateList = true;<br class="">
-<br class="">
- /// The start index of this \p Candidate.<br class="">
+private:<br class="">
+ /// The start index of this \p Candidate in the instruction list.<br class="">
unsigned StartIdx;<br class="">
<br class="">
/// The number of instructions in this \p Candidate.<br class="">
unsigned Len;<br class="">
<br class="">
- /// The index of this \p Candidate's \p OutlinedFunction in the list of<br class="">
+public:<br class="">
+ /// Set to false if the candidate overlapped with another candidate.<br class="">
+ bool InCandidateList = true;<br class="">
+<br class="">
+ /// \brief The index of this \p Candidate's \p OutlinedFunction in the list of<br class="">
/// \p OutlinedFunctions.<br class="">
unsigned FunctionIdx;<br class="">
<br class="">
/// Contains all target-specific information for this \p Candidate.<br class="">
TargetInstrInfo::<wbr class="">MachineOutlinerInfo MInfo;<br class="">
<br class="">
+ /// Return the number of instructions in this Candidate.<br class="">
+ unsigned length() const { return Len; }<br class="">
+<br class="">
+ /// Return the start index of this candidate.<br class="">
+ unsigned startIdx() const { return StartIdx; }<br class="">
+<br class="">
+ // Return the end index of this candidate.<br class="">
+ unsigned endIdx() const { return StartIdx + Len - 1; }<br class="">
+<br class="">
/// \brief The number of instructions that would be saved by outlining every<br class="">
/// candidate of this type.<br class="">
///<br class="">
@@ -125,7 +135,9 @@ struct Candidate {<br class="">
<br class="">
/// \brief Used to ensure that \p Candidates are outlined in an order that<br class="">
/// preserves the start and end indices of other \p Candidates.<br class="">
- bool operator<(const Candidate &RHS) const { return StartIdx > RHS.StartIdx; }<br class="">
+ bool operator<(const Candidate &RHS) const {<br class="">
+ return startIdx() > RHS.startIdx();<br class="">
+ }<br class="">
};<br class="">
<br class="">
/// \brief The information necessary to create an outlined function for some<br class="">
@@ -759,8 +771,8 @@ struct MachineOutliner : public ModulePa<br class="">
ModulePass::getAnalysisUsage(<wbr class="">AU);<br class="">
}<br class="">
<br class="">
- MachineOutliner(bool OutlineFromLinkOnceODRs = false) :<br class="">
- ModulePass(ID), OutlineFromLinkOnceODRs(<wbr class="">OutlineFromLinkOnceODRs) {<br class="">
+ MachineOutliner(bool OutlineFromLinkOnceODRs = false)<br class="">
+ : ModulePass(ID), OutlineFromLinkOnceODRs(<wbr class="">OutlineFromLinkOnceODRs) {<br class="">
initializeMachineOutlinerPass(<wbr class="">*PassRegistry::<wbr class="">getPassRegistry());<br class="">
}<br class="">
<br class="">
@@ -1060,8 +1072,8 @@ void MachineOutliner::<wbr class="">pruneOverlaps(std:<br class="">
unsigned FarthestPossibleIdx = 0;<br class="">
<br class="">
// Either the index is 0, or it's at most MaxCandidateLen indices away.<br class="">
- if (C1.StartIdx > MaxCandidateLen)<br class="">
- FarthestPossibleIdx = C1.StartIdx - MaxCandidateLen;<br class="">
+ if (C1.startIdx() > MaxCandidateLen)<br class="">
+ FarthestPossibleIdx = C1.startIdx() - MaxCandidateLen;<br class="">
<br class="">
// Compare against the candidates in the list that start at at most<br class="">
// FarthestPossibleIdx indices away from C1. There are at most<br class="">
@@ -1070,7 +1082,7 @@ void MachineOutliner::<wbr class="">pruneOverlaps(std:<br class="">
Candidate &C2 = *Sit;<br class="">
<br class="">
// Is this candidate too far away to overlap?<br class="">
- if (C2.StartIdx < FarthestPossibleIdx)<br class="">
+ if (C2.startIdx() < FarthestPossibleIdx)<br class="">
break;<br class="">
<br class="">
// If C2 was already pruned, or its function is no longer beneficial for<br class="">
@@ -1078,8 +1090,6 @@ void MachineOutliner::<wbr class="">pruneOverlaps(std:<br class="">
if (ShouldSkipCandidate(C2))<br class="">
continue;<br class="">
<br class="">
- unsigned C2End = C2.StartIdx + C2.Len - 1;<br class="">
-<br class="">
// Do C1 and C2 overlap?<br class="">
//<br class="">
// Not overlapping:<br class="">
@@ -1088,7 +1098,7 @@ void MachineOutliner::<wbr class="">pruneOverlaps(std:<br class="">
// We sorted our candidate list so C2Start <= C1Start. We know that<br class="">
// C2End > C2Start since each candidate has length >= 2. Therefore, all we<br class="">
// have to check is C2End < C2Start to see if we overlap.<br class="">
- if (C2End < C1.StartIdx)<br class="">
+ if (C2.endIdx() < C1.startIdx())<br class="">
continue;<br class="">
<br class="">
// C1 and C2 overlap.<br class="">
@@ -1202,10 +1212,11 @@ bool MachineOutliner::outline(<wbr class="">Module &M,<br class="">
continue;<br class="">
<br class="">
// If not, then outline it.<br class="">
- assert(C.StartIdx < Mapper.InstrList.size() && "Candidate out of bounds!");<br class="">
- MachineBasicBlock *MBB = (*Mapper.InstrList[C.StartIdx]<wbr class="">).getParent();<br class="">
- MachineBasicBlock::iterator StartIt = Mapper.InstrList[C.StartIdx];<br class="">
- unsigned EndIdx = C.StartIdx + C.Len - 1;<br class="">
+ assert(C.startIdx() < Mapper.InstrList.size() &&<br class="">
+ "Candidate out of bounds!");<br class="">
+ MachineBasicBlock *MBB = (*Mapper.InstrList[C.startIdx(<wbr class="">)]).getParent();<br class="">
+ MachineBasicBlock::iterator StartIt = Mapper.InstrList[C.startIdx()]<wbr class="">;<br class="">
+ unsigned EndIdx = C.endIdx();<br class="">
<br class="">
assert(EndIdx < Mapper.InstrList.size() && "Candidate out of bounds!");<br class="">
MachineBasicBlock::iterator EndIt = Mapper.InstrList[EndIdx];<br class="">
@@ -1225,7 +1236,7 @@ bool MachineOutliner::outline(<wbr class="">Module &M,<br class="">
<br class="">
// Insert a call to the new function and erase the old sequence.<br class="">
TII.insertOutlinedCall(M, *MBB, StartIt, *MF, C.MInfo);<br class="">
- StartIt = Mapper.InstrList[C.StartIdx];<br class="">
+ StartIt = Mapper.InstrList[C.startIdx()]<wbr class="">;<br class="">
MBB->erase(StartIt, EndIt);<br class="">
<br class="">
OutlinedSomething = true;<br class="">
<br class="">
<br class="">
______________________________<wbr class="">_________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>