[compiler-rt] r295967 - [Xray] fix building the runtime with GCC.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 23 04:49:42 PST 2017
Author: d0k
Date: Thu Feb 23 06:49:41 2017
New Revision: 295967
URL: http://llvm.org/viewvc/llvm-project?rev=295967&view=rev
Log:
[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.
Modified:
compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
compiler-rt/trunk/lib/xray/xray_fdr_logging.h
Modified: compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_fdr_logging.cc?rev=295967&r1=295966&r2=295967&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_fdr_logging.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_fdr_logging.cc Thu Feb 23 06:49:41 2017
@@ -190,8 +190,8 @@ void setupNewBuffer(const BufferQueue::B
// 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::B
{
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::B
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,
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_INSTR
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;
}
Modified: compiler-rt/trunk/lib/xray/xray_fdr_logging.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_fdr_logging.h?rev=295967&r1=295966&r2=295967&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_fdr_logging.h (original)
+++ compiler-rt/trunk/lib/xray/xray_fdr_logging.h Thu Feb 23 06:49:41 2017
@@ -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) ==
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
More information about the llvm-commits
mailing list