diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2017-02-23 12:49:41 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2017-02-23 12:49:41 +0000 |
| commit | 7654191e703ec7c9433885b8c4e38d20381dff2c (patch) | |
| tree | b6319dd9bc3722fed4be0af90bafb426d036d3bb | |
| parent | 59d23bbdc665c9d62bd9e6d598bfbaa73960ed7e (diff) | |
| download | bcm5719-llvm-7654191e703ec7c9433885b8c4e38d20381dff2c.tar.gz bcm5719-llvm-7654191e703ec7c9433885b8c4e38d20381dff2c.zip | |
[Xray] fix building the runtime with GCC.
GCC has a warning about enum bitfields that cannot be disabled. Do the
ugly thing and go through uint8_t for all the values.
llvm-svn: 295967
| -rw-r--r-- | compiler-rt/lib/xray/xray_fdr_logging.cc | 30 | ||||
| -rw-r--r-- | compiler-rt/lib/xray/xray_fdr_logging.h | 9 |
2 files changed, 21 insertions, 18 deletions
diff --git a/compiler-rt/lib/xray/xray_fdr_logging.cc b/compiler-rt/lib/xray/xray_fdr_logging.cc index e111dbfe38b..44ec8fe4bfa 100644 --- a/compiler-rt/lib/xray/xray_fdr_logging.cc +++ b/compiler-rt/lib/xray/xray_fdr_logging.cc @@ -190,8 +190,8 @@ void setupNewBuffer(const BufferQueue::Buffer &Buffer) XRAY_NEVER_INSTRUMENT { // point we only write down the following bytes: // - Thread ID (pid_t, 4 bytes) auto &NewBuffer = *reinterpret_cast<MetadataRecord *>(&Records[0]); - NewBuffer.Type = RecordType::Metadata; - NewBuffer.RecordKind = MetadataRecord::RecordKinds::NewBuffer; + NewBuffer.Type = uint8_t(RecordType::Metadata); + NewBuffer.RecordKind = uint8_t(MetadataRecord::RecordKinds::NewBuffer); pid_t Tid = syscall(SYS_gettid); std::memcpy(&NewBuffer.Data, &Tid, sizeof(pid_t)); } @@ -200,8 +200,9 @@ void setupNewBuffer(const BufferQueue::Buffer &Buffer) XRAY_NEVER_INSTRUMENT { { static_assert(sizeof(time_t) <= 8, "time_t needs to be at most 8 bytes"); auto &WalltimeMarker = *reinterpret_cast<MetadataRecord *>(&Records[1]); - WalltimeMarker.Type = RecordType::Metadata; - WalltimeMarker.RecordKind = MetadataRecord::RecordKinds::WalltimeMarker; + WalltimeMarker.Type = uint8_t(RecordType::Metadata); + WalltimeMarker.RecordKind = + uint8_t(MetadataRecord::RecordKinds::WalltimeMarker); timespec TS{0, 0}; clock_gettime(CLOCK_MONOTONIC, &TS); @@ -219,8 +220,8 @@ void setupNewBuffer(const BufferQueue::Buffer &Buffer) XRAY_NEVER_INSTRUMENT { void writeNewCPUIdMetadata(uint16_t CPU, uint64_t TSC) XRAY_NEVER_INSTRUMENT { MetadataRecord NewCPUId; - NewCPUId.Type = RecordType::Metadata; - NewCPUId.RecordKind = MetadataRecord::RecordKinds::NewCPUId; + NewCPUId.Type = uint8_t(RecordType::Metadata); + NewCPUId.RecordKind = uint8_t(MetadataRecord::RecordKinds::NewCPUId); // The data for the New CPU will contain the following bytes: // - CPU ID (uint16_t, 2 bytes) @@ -234,8 +235,8 @@ void writeNewCPUIdMetadata(uint16_t CPU, uint64_t TSC) XRAY_NEVER_INSTRUMENT { void writeEOBMetadata() XRAY_NEVER_INSTRUMENT { MetadataRecord EOBMeta; - EOBMeta.Type = RecordType::Metadata; - EOBMeta.RecordKind = MetadataRecord::RecordKinds::EndOfBuffer; + EOBMeta.Type = uint8_t(RecordType::Metadata); + EOBMeta.RecordKind = uint8_t(MetadataRecord::RecordKinds::EndOfBuffer); // For now we don't write any bytes into the Data field. std::memcpy(RecordPtr, &EOBMeta, sizeof(MetadataRecord)); RecordPtr += sizeof(MetadataRecord); @@ -243,8 +244,8 @@ void writeEOBMetadata() XRAY_NEVER_INSTRUMENT { void writeTSCWrapMetadata(uint64_t TSC) XRAY_NEVER_INSTRUMENT { MetadataRecord TSCWrap; - TSCWrap.Type = RecordType::Metadata; - TSCWrap.RecordKind = MetadataRecord::RecordKinds::TSCWrap; + TSCWrap.Type = uint8_t(RecordType::Metadata); + TSCWrap.RecordKind = uint8_t(MetadataRecord::RecordKinds::TSCWrap); // The data for the TSCWrap record contains the following bytes: // - Full TSC (uint64_t, 8 bytes) @@ -447,7 +448,7 @@ void fdrLoggingHandleArg0(int32_t FuncId, AlignedFuncRecordBuffer; auto &FuncRecord = *reinterpret_cast<FunctionRecord *>(&AlignedFuncRecordBuffer); - FuncRecord.Type = RecordType::Function; + FuncRecord.Type = uint8_t(RecordType::Function); // Only get the lower 28 bits of the function id. FuncRecord.FuncId = FuncId & ~(0x0F << 28); @@ -493,13 +494,14 @@ void fdrLoggingHandleArg0(int32_t FuncId, switch (Entry) { case XRayEntryType::ENTRY: - FuncRecord.RecordKind = FunctionRecord::RecordKinds::FunctionEnter; + FuncRecord.RecordKind = uint8_t(FunctionRecord::RecordKinds::FunctionEnter); break; case XRayEntryType::EXIT: - FuncRecord.RecordKind = FunctionRecord::RecordKinds::FunctionExit; + FuncRecord.RecordKind = uint8_t(FunctionRecord::RecordKinds::FunctionExit); break; case XRayEntryType::TAIL: - FuncRecord.RecordKind = FunctionRecord::RecordKinds::FunctionTailExit; + FuncRecord.RecordKind = + uint8_t(FunctionRecord::RecordKinds::FunctionTailExit); break; } diff --git a/compiler-rt/lib/xray/xray_fdr_logging.h b/compiler-rt/lib/xray/xray_fdr_logging.h index cade135e302..28c829625bd 100644 --- a/compiler-rt/lib/xray/xray_fdr_logging.h +++ b/compiler-rt/lib/xray/xray_fdr_logging.h @@ -34,7 +34,7 @@ enum class RecordType : uint8_t { // additional bytes in the end to hold free-form data. struct alignas(16) MetadataRecord { // A MetadataRecord must always have a type of 1. - RecordType Type : 1; + /* RecordType */ uint8_t Type : 1; // Each kind of record is represented as a 7-bit value (even though we use an // unsigned 8-bit enum class to do so). @@ -45,7 +45,8 @@ struct alignas(16) MetadataRecord { TSCWrap, WalltimeMarker, }; - RecordKinds RecordKind : 7; // Use 7 bits to identify this record type. + // Use 7 bits to identify this record type. + /* RecordKinds */ uint8_t RecordKind : 7; char Data[15]; } __attribute__((packed)); @@ -53,13 +54,13 @@ static_assert(sizeof(MetadataRecord) == 16, "Wrong size for MetadataRecord."); struct alignas(8) FunctionRecord { // A FunctionRecord must always have a type of 0. - RecordType Type : 1; + /* RecordType */ uint8_t Type : 1; enum class RecordKinds { FunctionEnter = 0x00, FunctionExit = 0x01, FunctionTailExit = 0x02, }; - RecordKinds RecordKind : 3; + /* RecordKinds */ uint8_t RecordKind : 3; // We only use 28 bits of the function ID, so that we can use as few bytes as // possible. This means we only support 2^28 (268,435,456) unique function ids |

