aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llvm/tools/llvm-profgen/DataAccessPerfReader.cpp57
-rw-r--r--llvm/tools/llvm-profgen/ProfiledBinary.cpp6
2 files changed, 3 insertions, 60 deletions
diff --git a/llvm/tools/llvm-profgen/DataAccessPerfReader.cpp b/llvm/tools/llvm-profgen/DataAccessPerfReader.cpp
index 9c0858e..74ca012 100644
--- a/llvm/tools/llvm-profgen/DataAccessPerfReader.cpp
+++ b/llvm/tools/llvm-profgen/DataAccessPerfReader.cpp
@@ -15,27 +15,6 @@ void DataAccessPerfReader::parsePerfTraces() {
parsePerfTrace(PerfTraceFilename);
}
-static void testPerfSampleRecordRegex() {
- std::regex logRegex(
- R"(^.*?PERF_RECORD_SAMPLE\(.*?\):\s*(\d+)\/(\d+):\s*(0x[0-9a-fA-F]+)\s+period:\s*\d+\s+addr:\s*(0x[0-9a-fA-F]+)$)");
-
- std::smatch testMatch;
- const std::string testLine =
- "2193330181938979 0xa88 [0x48]: PERF_RECORD_SAMPLE(IP, 0x4002): "
- "1807344/1807344: 0x260b45 period: 100 addr: 0x200630";
- if (std::regex_search(testLine, testMatch, logRegex)) {
- if (testMatch.size() != 5) {
- exitWithError("Regex did not match expected number of groups.");
- }
- for (size_t i = 0; i < testMatch.size(); ++i) {
- errs() << "Group " << i << ": " << testMatch[i] << "\n";
- }
- // errs() << "Test line matched successfully.\n";
- } else {
- exitWithError("Test line did not match regex.");
- }
-}
-
// Ignore mmap events.
void DataAccessPerfReader::parsePerfTrace(StringRef PerfTrace) {
std::regex logRegex(
@@ -56,11 +35,8 @@ void DataAccessPerfReader::parsePerfTrace(StringRef PerfTrace) {
PerfScriptReader::MMapEvent MMap;
if (Line.contains("PERF_RECORD_MMAP2")) {
if (PerfScriptReader::extractMMapEventForBinary(Binary, Line, MMap)) {
- errs() << "MMap event found: "
- << "PID: " << MMap.PID
- << ", Address: " << format("0x%llx", MMap.Address)
- << ", Size: " << MMap.Size << ", Offset: " << MMap.Offset
- << ", Binary Path: " << MMap.BinaryPath << "\n";
+ // TODO: This is a hack to avoid mapping binary address for data section
+ // mappings.
if (MMap.Offset == 0) {
updateBinaryAddress(MMap);
}
@@ -72,14 +48,6 @@ void DataAccessPerfReader::parsePerfTrace(StringRef PerfTrace) {
// Skip lines that do not contain "PERF_RECORD_SAMPLE".
continue;
}
- // errs() << "Processing line: " << Line << "\n";
-
- // if (IPSampleRegex.match(Line, &Matches)) {
- // errs() << "IP Captured: " << Matches.size() << "\n";
- // }
- // if (DataAddressRegex.match(Line, &Matches)) {
- // errs() << "Data Address Captured: " << Matches.size() << "\n";
- // }
std::smatch matches;
const std::string LineStr = Line.str();
@@ -91,16 +59,6 @@ void DataAccessPerfReader::parsePerfTrace(StringRef PerfTrace) {
uint64_t DataAddress = std::stoull(matches[4].str(), nullptr, 16);
uint64_t IP = std::stoull(matches[3].str(), nullptr, 16);
int32_t PID = std::stoi(matches[1].str());
- // if (DataAddress == 0x200630) {
- // errs() << "Find data address at 0x200630, IP: " << format("0x%llx",
- // IP)
- // << " pid is " << PID << "\n";
- // }
-
- // errs() << matches.size() << " matches found in line: " << LineStr <<
- // "\n"; for (const auto &Match : matches) {
- // errs() << "Match: " << Match.str() << "\n";
- // }
// Check if the PID matches the filter.
if (PIDFilter && *PIDFilter != PID) {
@@ -108,22 +66,13 @@ void DataAccessPerfReader::parsePerfTrace(StringRef PerfTrace) {
}
// Extract the address and count.
-
uint64_t CanonicalDataAddress =
Binary->canonicalizeVirtualAddress(DataAddress);
- // errs() << "Data address is " << format("0x" PRIx64 ":", DataAddress)
- // << " Canonical data address is "
- // << format("0x" PRIx64 ":", CanonicalDataAddress) << "\n";
+
AddressToCount[CanonicalDataAddress] += 1;
MatchedLine++;
- } else {
- // errs() << "\tNo match found for line: " << Line << "\n";
- UnmatchedLine++;
}
}
-
- errs() << "Total unmatched lines: " << UnmatchedLine << "\t"
- << "Matched lines: " << MatchedLine << "\n";
}
} // namespace llvm
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 3507389..d26b7ce 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -341,12 +341,6 @@ void ProfiledBinary::setPreferredTextSegmentAddresses(const ELFFile<ELFT> &Obj,
~(PageSize - 1U));
TextSegmentOffsets.push_back(Phdr.p_offset & ~(PageSize - 1U));
}
- // else if ((Phdr.p_flags & ELF::PF_R) && !TextSegmentOffsets.empty()) {
- // if (RecordDataSegment) {
- // ReadOnlyDataSegmentOffsets.push_back(Phdr.p_offset &
- // ~(PageSize - 1U));
- // }
- // }
}
}