From ec81ae37bd835b4d3d89d5e7ac1aeb17a636b752 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Sat, 10 Feb 2018 09:07:34 +0000 Subject: [PATCH] [XRay] Rename Buffer.Buffer to Buffer.Data Summary: some compiler (msvc) treats Buffer.Buffer as constructor and refuse to compile. NFC Authored by comicfans44. Reviewers: rnk, dberris Reviewed By: dberris Subscribers: llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40346 llvm-svn: 324807 --- compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc | 8 ++++---- compiler-rt/lib/xray/xray_buffer_queue.cc | 8 ++++---- compiler-rt/lib/xray/xray_buffer_queue.h | 2 +- compiler-rt/lib/xray/xray_fdr_logging.cc | 6 +++--- compiler-rt/lib/xray/xray_fdr_logging_impl.h | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc b/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc index 1ec7469ce187..c0d4ccb268d6 100644 --- a/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc +++ b/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc @@ -32,9 +32,9 @@ TEST(BufferQueueTest, GetAndRelease) { ASSERT_TRUE(Success); BufferQueue::Buffer Buf; ASSERT_EQ(Buffers.getBuffer(Buf), BufferQueue::ErrorCode::Ok); - ASSERT_NE(nullptr, Buf.Buffer); + ASSERT_NE(nullptr, Buf.Data); ASSERT_EQ(Buffers.releaseBuffer(Buf), BufferQueue::ErrorCode::Ok); - ASSERT_EQ(nullptr, Buf.Buffer); + ASSERT_EQ(nullptr, Buf.Data); } TEST(BufferQueueTest, GetUntilFailed) { @@ -53,7 +53,7 @@ TEST(BufferQueueTest, ReleaseUnknown) { BufferQueue Buffers(kSize, 1, Success); ASSERT_TRUE(Success); BufferQueue::Buffer Buf; - Buf.Buffer = reinterpret_cast(0xdeadbeef); + Buf.Data = reinterpret_cast(0xdeadbeef); Buf.Size = kSize; EXPECT_EQ(BufferQueue::ErrorCode::UnrecognizedBuffer, Buffers.releaseBuffer(Buf)); @@ -65,7 +65,7 @@ TEST(BufferQueueTest, ErrorsWhenFinalising) { ASSERT_TRUE(Success); BufferQueue::Buffer Buf; ASSERT_EQ(Buffers.getBuffer(Buf), BufferQueue::ErrorCode::Ok); - ASSERT_NE(nullptr, Buf.Buffer); + ASSERT_NE(nullptr, Buf.Data); ASSERT_EQ(Buffers.finalize(), BufferQueue::ErrorCode::Ok); BufferQueue::Buffer OtherBuf; ASSERT_EQ(BufferQueue::ErrorCode::QueueFinalizing, diff --git a/compiler-rt/lib/xray/xray_buffer_queue.cc b/compiler-rt/lib/xray/xray_buffer_queue.cc index a0018f6b0cba..a2e97f9438db 100644 --- a/compiler-rt/lib/xray/xray_buffer_queue.cc +++ b/compiler-rt/lib/xray/xray_buffer_queue.cc @@ -37,7 +37,7 @@ BufferQueue::BufferQueue(size_t B, size_t N, bool &Success) return; } auto &Buf = T.Buff; - Buf.Buffer = Tmp; + Buf.Data = Tmp; Buf.Size = B; Buf.Extents = reinterpret_cast(Extents); OwnedBuffers[i] = Tmp; @@ -68,7 +68,7 @@ BufferQueue::ErrorCode BufferQueue::releaseBuffer(Buffer &Buf) { // Blitz through the buffers array to find the buffer. bool Found = false; for (auto I = OwnedBuffers, E = OwnedBuffers + BufferCount; I != E; ++I) { - if (*I == Buf.Buffer) { + if (*I == Buf.Data) { Found = true; break; } @@ -86,7 +86,7 @@ BufferQueue::ErrorCode BufferQueue::releaseBuffer(Buffer &Buf) { // Now that the buffer has been released, we mark it as "used". First->Buff = Buf; First->Used = true; - Buf.Buffer = nullptr; + Buf.Data = nullptr; Buf.Size = 0; --LiveBuffers; if (++First == (Buffers + BufferCount)) @@ -106,7 +106,7 @@ BufferQueue::~BufferQueue() { for (auto I = Buffers, E = Buffers + BufferCount; I != E; ++I) { auto &T = *I; auto &Buf = T.Buff; - InternalFree(Buf.Buffer); + InternalFree(Buf.Data); InternalFree(Buf.Extents); } delete[] Buffers; diff --git a/compiler-rt/lib/xray/xray_buffer_queue.h b/compiler-rt/lib/xray/xray_buffer_queue.h index 1ceb58274616..32f852d40fa3 100644 --- a/compiler-rt/lib/xray/xray_buffer_queue.h +++ b/compiler-rt/lib/xray/xray_buffer_queue.h @@ -33,7 +33,7 @@ class BufferQueue { }; struct Buffer { - void *Buffer = nullptr; + void *Data = nullptr; size_t Size = 0; BufferExtents* Extents; }; diff --git a/compiler-rt/lib/xray/xray_fdr_logging.cc b/compiler-rt/lib/xray/xray_fdr_logging.cc index 1bfa10c21f5c..72776e2c17fb 100644 --- a/compiler-rt/lib/xray/xray_fdr_logging.cc +++ b/compiler-rt/lib/xray/xray_fdr_logging.cc @@ -136,8 +136,8 @@ XRayLogFlushStatus fdrLoggingFlush() XRAY_NEVER_INSTRUMENT { retryingWriteAll(Fd, reinterpret_cast(&ExtentsRecord), reinterpret_cast(&ExtentsRecord) + sizeof(MetadataRecord)); - retryingWriteAll(Fd, reinterpret_cast(B.Buffer), - reinterpret_cast(B.Buffer) + BufferExtents); + retryingWriteAll(Fd, reinterpret_cast(B.Data), + reinterpret_cast(B.Data) + BufferExtents); } }); @@ -341,7 +341,7 @@ XRayLogInitStatus fdrLoggingInit(std::size_t BufferSize, std::size_t BufferMax, auto EC = TLD.BQ->releaseBuffer(TLD.Buffer); if (EC != BufferQueue::ErrorCode::Ok) Report("At thread exit, failed to release buffer at %p; error=%s\n", - TLD.Buffer.Buffer, BufferQueue::getErrorString(EC)); + TLD.Buffer.Data, BufferQueue::getErrorString(EC)); }); return false; }(); diff --git a/compiler-rt/lib/xray/xray_fdr_logging_impl.h b/compiler-rt/lib/xray/xray_fdr_logging_impl.h index 59eab55b2573..d1cbda962887 100644 --- a/compiler-rt/lib/xray/xray_fdr_logging_impl.h +++ b/compiler-rt/lib/xray/xray_fdr_logging_impl.h @@ -235,7 +235,7 @@ inline void setupNewBuffer(int (*wall_clock_reader)( clockid_t, struct timespec *)) XRAY_NEVER_INSTRUMENT { auto &TLD = getThreadLocalData(); auto &B = TLD.Buffer; - TLD.RecordPtr = static_cast(B.Buffer); + TLD.RecordPtr = static_cast(B.Data); pid_t Tid = syscall(SYS_gettid); timespec TS{0, 0}; // This is typically clock_gettime, but callers have injection ability. @@ -447,7 +447,7 @@ inline bool releaseThreadLocalBuffer(BufferQueue &BQArg) { auto &TLD = getThreadLocalData(); auto EC = BQArg.releaseBuffer(TLD.Buffer); if (EC != BufferQueue::ErrorCode::Ok) { - Report("Failed to release buffer at %p; error=%s\n", TLD.Buffer.Buffer, + Report("Failed to release buffer at %p; error=%s\n", TLD.Buffer.Data, BufferQueue::getErrorString(EC)); return false; } @@ -459,7 +459,7 @@ inline bool prepareBuffer(uint64_t TSC, unsigned char CPU, struct timespec *), size_t MaxSize) XRAY_NEVER_INSTRUMENT { auto &TLD = getThreadLocalData(); - char *BufferStart = static_cast(TLD.Buffer.Buffer); + char *BufferStart = static_cast(TLD.Buffer.Data); if ((TLD.RecordPtr + MaxSize) > (BufferStart + TLD.Buffer.Size)) { if (!releaseThreadLocalBuffer(*TLD.BQ)) return false; @@ -507,7 +507,7 @@ isLogInitializedAndReady(BufferQueue *LBQ, uint64_t TSC, unsigned char CPU, TLD.RecordPtr = nullptr; } - if (TLD.Buffer.Buffer == nullptr) { + if (TLD.Buffer.Data == nullptr) { auto EC = LBQ->getBuffer(TLD.Buffer); if (EC != BufferQueue::ErrorCode::Ok) { auto LS = __sanitizer::atomic_load(&LoggingStatus, @@ -573,7 +573,7 @@ inline uint32_t writeCurrentCPUTSC(ThreadLocalData &TLD, uint64_t TSC, inline void endBufferIfFull() XRAY_NEVER_INSTRUMENT { auto &TLD = getThreadLocalData(); - auto BufferStart = static_cast(TLD.Buffer.Buffer); + auto BufferStart = static_cast(TLD.Buffer.Data); if ((TLD.RecordPtr + MetadataRecSize) - BufferStart <= ptrdiff_t{MetadataRecSize}) { if (!releaseThreadLocalBuffer(*TLD.BQ)) @@ -656,7 +656,7 @@ inline void processFunctionHook(int32_t FuncId, XRayEntryType Entry, } // By this point, we are now ready to write up to 40 bytes (explained above). - assert((TLD.RecordPtr + MaxSize) - static_cast(TLD.Buffer.Buffer) >= + assert((TLD.RecordPtr + MaxSize) - static_cast(TLD.Buffer.Data) >= static_cast(MetadataRecSize) && "Misconfigured BufferQueue provided; Buffer size not large enough.");