[compiler-rt] [llvm] [XRay] Remove unused argument of DataExtractor constructor (NFC) (PR #191864)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 22:02:48 PDT 2026


https://github.com/s-barannikov updated https://github.com/llvm/llvm-project/pull/191864

>From 4b5b435abe438ad4bf9941b454eaab961e3521a6 Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Mon, 13 Apr 2026 21:02:40 +0300
Subject: [PATCH] [xray] Remove unused argument of DataExtractor constructor
 (NFC)

`AddressSize` parameter is not used by `DataExtractor` and will be
removed in the future. See #190519 for more context.
---
 .../xray/tests/unit/fdr_controller_test.cpp   | 28 +++++++++----------
 .../xray/tests/unit/fdr_log_writer_test.cpp   |  6 ++--
 llvm/lib/XRay/InstrumentationMap.cpp          |  4 +--
 llvm/lib/XRay/Profile.cpp                     |  2 +-
 llvm/lib/XRay/Trace.cpp                       | 10 +++----
 llvm/tools/llvm-xray/xray-fdr-dump.cpp        |  2 +-
 .../XRay/FDRProducerConsumerTest.cpp          |  4 +--
 llvm/unittests/XRay/FDRTraceWriterTest.cpp    |  6 ++--
 8 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cpp b/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cpp
index 3cf400786d64f..15cc09b679ebc 100644
--- a/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cpp
+++ b/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cpp
@@ -67,7 +67,7 @@ TEST_F(FunctionSequenceTest, DefaultInitFinalizeFlush) {
 
   // Serialize the buffers then test to see we find the expected records.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr,
@@ -91,7 +91,7 @@ TEST_F(FunctionSequenceTest, BoundaryFuncIdEncoding) {
 
   // Serialize the buffers then test to see we find the expected records.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr,
@@ -112,7 +112,7 @@ TEST_F(FunctionSequenceTest, ThresholdsAreEnforced) {
   // Serialize the buffers then test to see we find the *no* records, because
   // the function entry-exit comes under the cycle threshold.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(TraceOrErr, HasValue(IsEmpty()));
 }
@@ -127,7 +127,7 @@ TEST_F(FunctionSequenceTest, ArgsAreHandledAndKept) {
   // Serialize the buffers then test to see we find the function enter arg
   // record with the specified argument.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr,
@@ -151,7 +151,7 @@ TEST_F(FunctionSequenceTest, PreservedCallsHaveCorrectTSC) {
   // Serialize the buffers then test to see if we find the remaining records,
   // because the function entry-exit comes under the cycle threshold.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr,
@@ -175,7 +175,7 @@ TEST_F(FunctionSequenceTest, PreservedCallsSupportLargeDeltas) {
   // Serialize the buffer then test to see if we find the right TSC with a large
   // delta.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr,
@@ -208,7 +208,7 @@ TEST_F(FunctionSequenceTest, RewindingMultipleCalls) {
   // Serialize the buffers then test to see we find that all the calls have been
   // unwound because all of them are under the cycle counter threshold.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(TraceOrErr, HasValue(IsEmpty()));
 }
@@ -242,7 +242,7 @@ TEST_F(FunctionSequenceTest, RewindingIntermediaryTailExits) {
   // Serialize the buffers then test to see we find that all the calls have been
   // unwound because all of them are under the cycle counter threshold.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(TraceOrErr, HasValue(IsEmpty()));
 }
@@ -280,7 +280,7 @@ TEST_F(FunctionSequenceTest, RewindingAfterMigration) {
   // Serialize buffers then test that we can find all the events that span the
   // CPU migration.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr,
@@ -326,7 +326,7 @@ TEST_F(BufferManagementTest, HandlesOverflow) {
   ASSERT_THAT(BQ->finalize(), Eq(BufferQueue::ErrorCode::Ok));
 
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(TraceOrErr, HasValue(SizeIs(kBuffers * 2)));
 }
@@ -343,7 +343,7 @@ TEST_F(BufferManagementTest, HandlesOverflowWithArgs) {
   ASSERT_THAT(BQ->finalize(), Eq(BufferQueue::ErrorCode::Ok));
 
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(TraceOrErr, HasValue(SizeIs(kBuffers)));
 }
@@ -361,7 +361,7 @@ TEST_F(BufferManagementTest, HandlesOverflowWithCustomEvents) {
   ASSERT_THAT(BQ->finalize(), Eq(BufferQueue::ErrorCode::Ok));
 
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
 
   // We expect to also now count the kBuffers/2 custom event records showing up
@@ -389,7 +389,7 @@ TEST_F(BufferManagementTest, HandlesFinalizedBufferQueue) {
   // We expect that we'll only be able to find the function enter event, but not
   // the function exit event.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr, HasValue(ElementsAre(AllOf(
@@ -412,7 +412,7 @@ TEST_F(BufferManagementTest, HandlesGenerationalBufferQueue) {
   // not the function enter event, since we only have information about the new
   // generation of the buffers.
   std::string Serialized = serialize(*BQ, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr, HasValue(ElementsAre(AllOf(
diff --git a/compiler-rt/lib/xray/tests/unit/fdr_log_writer_test.cpp b/compiler-rt/lib/xray/tests/unit/fdr_log_writer_test.cpp
index 17072462a4ad7..040377763c420 100644
--- a/compiler-rt/lib/xray/tests/unit/fdr_log_writer_test.cpp
+++ b/compiler-rt/lib/xray/tests/unit/fdr_log_writer_test.cpp
@@ -64,7 +64,7 @@ TEST(FdrLogWriterTest, WriteSomeRecords) {
   // flat buffer that we would see if they were laid out in a file. This also
   // means we need to write out the header manually.
   std::string Serialized = serialize(Buffers, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr,
@@ -117,7 +117,7 @@ TEST(FdrLogWriterTest, ReuseBuffers) {
 
   // Then we validate that we only see the single enter record.
   std::string Serialized = serialize(Buffers, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(
       TraceOrErr, HasValue(ElementsAre(AllOf(
@@ -152,7 +152,7 @@ TEST(FdrLogWriterTest, UnwriteRecords) {
   // We've un-done the two function records we've written, and now we expect
   // that we don't have any function records in the trace.
   std::string Serialized = serialize(Buffers, 3);
-  llvm::DataExtractor DE(Serialized, true, 8);
+  llvm::DataExtractor DE(Serialized, true);
   auto TraceOrErr = llvm::xray::loadTrace(DE);
   EXPECT_THAT_EXPECTED(TraceOrErr, HasValue(IsEmpty()));
 }
diff --git a/llvm/lib/XRay/InstrumentationMap.cpp b/llvm/lib/XRay/InstrumentationMap.cpp
index 5da09a57596a9..71d9e8f51c610 100644
--- a/llvm/lib/XRay/InstrumentationMap.cpp
+++ b/llvm/lib/XRay/InstrumentationMap.cpp
@@ -167,9 +167,7 @@ loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
   int32_t FuncId = 1;
   uint64_t CurFn = 0;
   for (; C != Contents.bytes_end(); C += ELFSledEntrySize) {
-    DataExtractor Extractor(
-        StringRef(reinterpret_cast<const char *>(C), ELFSledEntrySize), true,
-        8);
+    DataExtractor Extractor(ArrayRef<uint8_t>(C, ELFSledEntrySize), true);
     Sleds.push_back({});
     auto &Entry = Sleds.back();
     uint64_t OffsetPtr = 0;
diff --git a/llvm/lib/XRay/Profile.cpp b/llvm/lib/XRay/Profile.cpp
index ecb767bfc2c2a..9eef95ff00a4a 100644
--- a/llvm/lib/XRay/Profile.cpp
+++ b/llvm/lib/XRay/Profile.cpp
@@ -279,7 +279,7 @@ Expected<Profile> xray::loadProfile(StringRef Filename) {
 
   Profile P;
   uint64_t Offset = 0;
-  DataExtractor Extractor(Data, true, 8);
+  DataExtractor Extractor(Data, true);
 
   // For each block we get from the file:
   while (Offset != MappedFile.size()) {
diff --git a/llvm/lib/XRay/Trace.cpp b/llvm/lib/XRay/Trace.cpp
index 14a3f01be66bd..89f8acc97adb8 100644
--- a/llvm/lib/XRay/Trace.cpp
+++ b/llvm/lib/XRay/Trace.cpp
@@ -42,7 +42,7 @@ static Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
         "Invalid-sized XRay data.",
         std::make_error_code(std::errc::invalid_argument));
 
-  DataExtractor Reader(Data, IsLittleEndian, 8);
+  DataExtractor Reader(Data, IsLittleEndian);
   uint64_t OffsetPtr = 0;
   auto FileHeaderOrError = readBinaryFormatHeader(Reader, OffsetPtr);
   if (!FileHeaderOrError)
@@ -270,7 +270,7 @@ static Error loadFDRLog(StringRef Data, bool IsLittleEndian,
   if (Data.size() < 32)
     return createStringError(std::make_error_code(std::errc::invalid_argument),
                              "Not enough bytes for an XRay FDR log.");
-  DataExtractor DE(Data, IsLittleEndian, 8);
+  DataExtractor DE(Data, IsLittleEndian);
 
   uint64_t OffsetPtr = 0;
   auto FileHeaderOrError = readBinaryFormatHeader(DE, OffsetPtr);
@@ -405,10 +405,10 @@ Expected<Trace> llvm::xray::loadTraceFile(StringRef Filename, bool Sort) {
   auto Data = StringRef(MappedFile.data(), MappedFile.size());
 
   // TODO: Lift the endianness and implementation selection here.
-  DataExtractor LittleEndianDE(Data, true, 8);
+  DataExtractor LittleEndianDE(Data, true);
   auto TraceOrError = loadTrace(LittleEndianDE, Sort);
   if (!TraceOrError) {
-    DataExtractor BigEndianDE(Data, false, 8);
+    DataExtractor BigEndianDE(Data, false);
     consumeError(TraceOrError.takeError());
     TraceOrError = loadTrace(BigEndianDE, Sort);
   }
@@ -430,7 +430,7 @@ Expected<Trace> llvm::xray::loadTrace(const DataExtractor &DE, bool Sort) {
   //
   // Only if we can't load either the binary or the YAML format will we yield an
   // error.
-  DataExtractor HeaderExtractor(DE.getData(), DE.isLittleEndian(), 8);
+  DataExtractor HeaderExtractor(DE.getData(), DE.isLittleEndian());
   uint64_t OffsetPtr = 0;
   uint16_t Version = HeaderExtractor.getU16(&OffsetPtr);
   uint16_t Type = HeaderExtractor.getU16(&OffsetPtr);
diff --git a/llvm/tools/llvm-xray/xray-fdr-dump.cpp b/llvm/tools/llvm-xray/xray-fdr-dump.cpp
index 017ff03ce30ec..5cd90eff46a35 100644
--- a/llvm/tools/llvm-xray/xray-fdr-dump.cpp
+++ b/llvm/tools/llvm-xray/xray-fdr-dump.cpp
@@ -50,7 +50,7 @@ static CommandRegistration Unused(&Dump, []() -> Error {
       EC);
   sys::fs::closeFile(*FDOrErr);
 
-  DataExtractor DE(StringRef(MappedFile.data(), MappedFile.size()), true, 8);
+  DataExtractor DE(StringRef(MappedFile.data(), MappedFile.size()), true);
   uint64_t OffsetPtr = 0;
 
   auto FileHeaderOrError = readBinaryFormatHeader(DE, OffsetPtr);
diff --git a/llvm/unittests/XRay/FDRProducerConsumerTest.cpp b/llvm/unittests/XRay/FDRProducerConsumerTest.cpp
index 24acb8998b727..3eeab3158cc8d 100644
--- a/llvm/unittests/XRay/FDRProducerConsumerTest.cpp
+++ b/llvm/unittests/XRay/FDRProducerConsumerTest.cpp
@@ -128,7 +128,7 @@ TYPED_TEST_P(RoundTripTest, RoundTripsSingleValue) {
   auto &R = this->Rec;
   ASSERT_FALSE(errorToBool(R->apply(*this->Writer)));
 
-  DataExtractor DE(this->Data, sys::IsLittleEndianHost, 8);
+  DataExtractor DE(this->Data, sys::IsLittleEndianHost);
   uint64_t OffsetPtr = 0;
   auto HeaderOrErr = readBinaryFormatHeader(DE, OffsetPtr);
   if (!HeaderOrErr)
@@ -167,7 +167,7 @@ TYPED_TEST_P(RoundTripTestV5, RoundTripsSingleValue) {
   auto &R = this->Rec;
   ASSERT_FALSE(errorToBool(R->apply(*this->Writer)));
 
-  DataExtractor DE(this->Data, sys::IsLittleEndianHost, 8);
+  DataExtractor DE(this->Data, sys::IsLittleEndianHost);
   uint64_t OffsetPtr = 0;
   auto HeaderOrErr = readBinaryFormatHeader(DE, OffsetPtr);
   if (!HeaderOrErr)
diff --git a/llvm/unittests/XRay/FDRTraceWriterTest.cpp b/llvm/unittests/XRay/FDRTraceWriterTest.cpp
index 32c75e440a40e..fa85d679bff36 100644
--- a/llvm/unittests/XRay/FDRTraceWriterTest.cpp
+++ b/llvm/unittests/XRay/FDRTraceWriterTest.cpp
@@ -54,7 +54,7 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion3) {
     ASSERT_FALSE(errorToBool(P->apply(Writer)));
 
   // Then from here we load the Trace file.
-  DataExtractor DE(Data, sys::IsLittleEndianHost, 8);
+  DataExtractor DE(Data, sys::IsLittleEndianHost);
   auto TraceOrErr = loadTrace(DE, true);
   if (!TraceOrErr)
     FAIL() << TraceOrErr.takeError();
@@ -98,7 +98,7 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion2) {
     ASSERT_FALSE(errorToBool(P->apply(Writer)));
 
   // Then from here we load the Trace file.
-  DataExtractor DE(Data, sys::IsLittleEndianHost, 8);
+  DataExtractor DE(Data, sys::IsLittleEndianHost);
   auto TraceOrErr = loadTrace(DE, true);
   if (!TraceOrErr)
     FAIL() << TraceOrErr.takeError();
@@ -155,7 +155,7 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion1) {
   ASSERT_THAT(Data.size(), Eq(BufferSize + 32));
 
   // Then from here we load the Trace file.
-  DataExtractor DE(Data, sys::IsLittleEndianHost, 8);
+  DataExtractor DE(Data, sys::IsLittleEndianHost);
   auto TraceOrErr = loadTrace(DE, true);
   if (!TraceOrErr)
     FAIL() << TraceOrErr.takeError();



More information about the llvm-commits mailing list