summaryrefslogtreecommitdiffstats
path: root/llvm/lib/XRay/FDRRecordProducer.cpp
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2018-08-31 11:41:08 +0000
committerDean Michael Berris <dberris@google.com>2018-08-31 11:41:08 +0000
commitfc774e29d291de7b85ccb059b3319048b5cdbdbd (patch)
tree8a257e7b1a7ef693f55b65fbe34460cea2d18eda /llvm/lib/XRay/FDRRecordProducer.cpp
parent9d053074a1ad84a238de9bb434e2693b43715659 (diff)
downloadbcm5719-llvm-fc774e29d291de7b85ccb059b3319048b5cdbdbd.tar.gz
bcm5719-llvm-fc774e29d291de7b85ccb059b3319048b5cdbdbd.zip
[XRay] Remove array for Metadata Record Types
This simplifies the implementation of the metadata lookup by using scoped enums, rather than using enum classes. This way we can get the number-name mapping without having to resort to comments. Follow-up to D51289. llvm-svn: 341205
Diffstat (limited to 'llvm/lib/XRay/FDRRecordProducer.cpp')
-rw-r--r--llvm/lib/XRay/FDRRecordProducer.cpp68
1 files changed, 28 insertions, 40 deletions
diff --git a/llvm/lib/XRay/FDRRecordProducer.cpp b/llvm/lib/XRay/FDRRecordProducer.cpp
index ef2f6a47fee..4b010f1fa62 100644
--- a/llvm/lib/XRay/FDRRecordProducer.cpp
+++ b/llvm/lib/XRay/FDRRecordProducer.cpp
@@ -14,66 +14,54 @@ namespace xray {
namespace {
-// Keep this in sync with the values written in the XRay FDR mode runtime in
-// compiler-rt.
-enum class MetadataRecordKinds : uint8_t {
- NewBuffer,
- EndOfBuffer,
- NewCPUId,
- TSCWrap,
- WalltimeMarker,
- CustomEventMarker,
- CallArgument,
- BufferExtents,
- TypedEventMarker,
- Pid,
- // This is an end marker, used to identify the upper bound for this enum.
- EnumEndMarker,
-};
-
Expected<std::unique_ptr<Record>>
metadataRecordType(const XRayFileHeader &Header, uint8_t T) {
+ // Keep this in sync with the values written in the XRay FDR mode runtime in
+ // compiler-rt.
+ enum MetadataRecordKinds : uint8_t {
+ NewBufferKind,
+ EndOfBufferKind,
+ NewCPUIdKind,
+ TSCWrapKind,
+ WalltimeMarkerKind,
+ CustomEventMarkerKind,
+ CallArgumentKind,
+ BufferExtentsKind,
+ TypedEventMarkerKind,
+ PidKind,
+ // This is an end marker, used to identify the upper bound for this enum.
+ EnumEndMarker,
+ };
+
if (T >= static_cast<uint8_t>(MetadataRecordKinds::EnumEndMarker))
return createStringError(std::make_error_code(std::errc::invalid_argument),
"Invalid metadata record type: %d", T);
- static constexpr MetadataRecordKinds Mapping[] = {
- MetadataRecordKinds::NewBuffer,
- MetadataRecordKinds::EndOfBuffer,
- MetadataRecordKinds::NewCPUId,
- MetadataRecordKinds::TSCWrap,
- MetadataRecordKinds::WalltimeMarker,
- MetadataRecordKinds::CustomEventMarker,
- MetadataRecordKinds::CallArgument,
- MetadataRecordKinds::BufferExtents,
- MetadataRecordKinds::TypedEventMarker,
- MetadataRecordKinds::Pid,
- };
- switch (Mapping[T]) {
- case MetadataRecordKinds::NewBuffer:
+ switch (T) {
+ case MetadataRecordKinds::NewBufferKind:
return make_unique<NewBufferRecord>();
- case MetadataRecordKinds::EndOfBuffer:
+ case MetadataRecordKinds::EndOfBufferKind:
if (Header.Version >= 2)
return createStringError(
std::make_error_code(std::errc::executable_format_error),
"End of buffer records are no longer supported starting version "
"2 of the log.");
return make_unique<EndBufferRecord>();
- case MetadataRecordKinds::NewCPUId:
+ case MetadataRecordKinds::NewCPUIdKind:
return make_unique<NewCPUIDRecord>();
- case MetadataRecordKinds::TSCWrap:
+ case MetadataRecordKinds::TSCWrapKind:
return make_unique<TSCWrapRecord>();
- case MetadataRecordKinds::WalltimeMarker:
+ case MetadataRecordKinds::WalltimeMarkerKind:
return make_unique<WallclockRecord>();
- case MetadataRecordKinds::CustomEventMarker:
+ case MetadataRecordKinds::CustomEventMarkerKind:
return make_unique<CustomEventRecord>();
- case MetadataRecordKinds::CallArgument:
+ case MetadataRecordKinds::CallArgumentKind:
return make_unique<CallArgRecord>();
- case MetadataRecordKinds::BufferExtents:
+ case MetadataRecordKinds::BufferExtentsKind:
return make_unique<BufferExtents>();
- case MetadataRecordKinds::TypedEventMarker:
+ case MetadataRecordKinds::TypedEventMarkerKind:
return createStringError(std::make_error_code(std::errc::invalid_argument),
"Encountered an unsupported TypedEventMarker.");
- case MetadataRecordKinds::Pid:
+ case MetadataRecordKinds::PidKind:
return make_unique<PIDRecord>();
case MetadataRecordKinds::EnumEndMarker:
llvm_unreachable("Invalid MetadataRecordKind");
OpenPOWER on IntegriCloud