1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/lib/XRay/BlockIndexer.cpp
Dean Michael Berris 37533d7125 [XRay] Bug fixes for FDR custom event and arg-logging
Summary:
This change has a number of fixes for FDR mode in compiler-rt along with
changes to the tooling handling the traces in llvm.

In the runtime, we do the following:

- Advance the "last record" pointer appropriately when writing the
  custom event data in the log.

- Add XRAY_NEVER_INSTRUMENT in the rewinding routine.

- When collecting the argument of functions appropriately marked, we
  should not attempt to rewind them (and reset the counts of functions
  that can be re-wound).

In the tooling, we do the following:

- Remove the state logic in BlockIndexer and instead rely on the
  presence/absence of records to indicate blocks.

- Move the verifier into a loop associated with each block.

Reviewers: mboerger, eizan

Subscribers: llvm-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D51965

llvm-svn: 342122
2018-09-13 09:25:42 +00:00

89 lines
2.4 KiB
C++

//===- BlockIndexer.cpp - FDR Block Indexing VIsitor ----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// An implementation of the RecordVisitor which generates a mapping between a
// thread and a range of records representing a block.
//
//===----------------------------------------------------------------------===//
#include "llvm/XRay/BlockIndexer.h"
namespace llvm {
namespace xray {
Error BlockIndexer::visit(BufferExtents &) { return Error::success(); }
Error BlockIndexer::visit(WallclockRecord &R) {
CurrentBlock.Records.push_back(&R);
CurrentBlock.WallclockTime = &R;
return Error::success();
}
Error BlockIndexer::visit(NewCPUIDRecord &R) {
CurrentBlock.Records.push_back(&R);
return Error::success();
}
Error BlockIndexer::visit(TSCWrapRecord &R) {
CurrentBlock.Records.push_back(&R);
return Error::success();
}
Error BlockIndexer::visit(CustomEventRecord &R) {
CurrentBlock.Records.push_back(&R);
return Error::success();
}
Error BlockIndexer::visit(CallArgRecord &R) {
CurrentBlock.Records.push_back(&R);
return Error::success();
}
Error BlockIndexer::visit(PIDRecord &R) {
CurrentBlock.ProcessID = R.pid();
CurrentBlock.Records.push_back(&R);
return Error::success();
}
Error BlockIndexer::visit(NewBufferRecord &R) {
if (!CurrentBlock.Records.empty())
if (auto E = flush())
return E;
CurrentBlock.ThreadID = R.tid();
CurrentBlock.Records.push_back(&R);
return Error::success();
}
Error BlockIndexer::visit(EndBufferRecord &R) {
CurrentBlock.Records.push_back(&R);
return Error::success();
}
Error BlockIndexer::visit(FunctionRecord &R) {
CurrentBlock.Records.push_back(&R);
return Error::success();
}
Error BlockIndexer::flush() {
Index::iterator It;
std::tie(It, std::ignore) =
Indices.insert({{CurrentBlock.ProcessID, CurrentBlock.ThreadID}, {}});
It->second.push_back({CurrentBlock.ProcessID, CurrentBlock.ThreadID,
CurrentBlock.WallclockTime,
std::move(CurrentBlock.Records)});
CurrentBlock.ProcessID = 0;
CurrentBlock.ThreadID = 0;
CurrentBlock.Records = {};
CurrentBlock.WallclockTime = nullptr;
return Error::success();
}
} // namespace xray
} // namespace llvm