CallStackIterator begin() const;
CallStackIterator end() const { return CallStackIterator(N, /*End*/ true); }
CallStackIterator beginAfterSharedPrefix(CallStack &Other);
+ uint64_t back() const;
private:
const NodeT *N = nullptr;
CallStack<NodeT, IteratorT>::CallStackIterator::CallStackIterator(
const NodeT *N, bool End)
: N(N) {
- if (!N)
+ if (!N) {
+ Iter = nullptr;
return;
+ }
Iter = End ? N->StackIdIndices.end() : N->StackIdIndices.begin();
}
}
template <class NodeT, class IteratorT>
+uint64_t CallStack<NodeT, IteratorT>::back() const {
+ assert(N);
+ return N->StackIdIndices.back();
+}
+
+template <class NodeT, class IteratorT>
typename CallStack<NodeT, IteratorT>::CallStackIterator
CallStack<NodeT, IteratorT>::begin() const {
return CallStackIterator(N, /*End*/ false);
const MDNode *N, bool End);
template <>
uint64_t CallStack<MDNode, MDNode::op_iterator>::CallStackIterator::operator*();
+template <> uint64_t CallStack<MDNode, MDNode::op_iterator>::back() const;
} // end namespace memprof
} // end namespace llvm
auto *MIBMD = cast<const MDNode>(MIBOp);
MDNode *StackNode = getMIBStackNode(MIBMD);
CallStack<MDNode, MDNode::op_iterator> StackContext(StackNode);
+ uint64_t ExpectedBack = First ? 4 : 5;
+ EXPECT_EQ(StackContext.back(), ExpectedBack);
std::vector<uint64_t> StackIds;
for (auto ContextIter = StackContext.beginAfterSharedPrefix(InstCallsite);
ContextIter != StackContext.end(); ++ContextIter)
for (auto &MIB : AI.MIBs) {
CallStack<MIBInfo, SmallVector<unsigned>::const_iterator> StackContext(
&MIB);
+ uint64_t ExpectedBack = First ? 4 : 5;
+ EXPECT_EQ(Index->getStackIdAtIndex(StackContext.back()), ExpectedBack);
std::vector<uint64_t> StackIds;
for (auto StackIdIndex : StackContext)
StackIds.push_back(Index->getStackIdAtIndex(StackIdIndex));