aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
diff options
context:
space:
mode:
authorAiden Grossman <agrossman154@yahoo.com>2023-12-07 00:12:23 -0800
committerAiden Grossman <agrossman154@yahoo.com>2023-12-07 00:20:24 -0800
commitf1963fde9f8be49454d827d72b83ee8aaa78a9cc (patch)
tree033d83f7671587e88c758438daf1d69b2ffb36fc /llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
parent04ce9a34ea82647a61b4e2a2a3cc5c93cc2f0d7d (diff)
downloadllvm-f1963fde9f8be49454d827d72b83ee8aaa78a9cc.zip
llvm-f1963fde9f8be49454d827d72b83ee8aaa78a9cc.tar.gz
llvm-f1963fde9f8be49454d827d72b83ee8aaa78a9cc.tar.bz2
Reland "[llvm-exegesis] Add in snippet address annotation (#74218)"
This reverts commit 30d700117b772d94d8474ec56bd6f9cc423fc613. This relands commit 3ab41f912a6c219a93b87c257139822ea07c8863. When I was updating the patch to use llvm::to_integer, I only ran the lit tests and didn't run the unit tests, one of which started to fail. This patch fixes the broken unit test.
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index dd7c1a3..d1b0a58 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -416,9 +416,17 @@ private:
#endif // GLIBC_INITS_RSEQ
size_t FunctionDataCopySize = this->Function.FunctionBytes.size();
+ void *MapAddress = NULL;
+ int MapFlags = MAP_PRIVATE | MAP_ANONYMOUS;
+
+ if (Key.SnippetAddress != 0) {
+ MapAddress = reinterpret_cast<void *>(Key.SnippetAddress);
+ MapFlags |= MAP_FIXED_NOREPLACE;
+ }
+
char *FunctionDataCopy =
- (char *)mmap(NULL, FunctionDataCopySize, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+ (char *)mmap(MapAddress, FunctionDataCopySize, PROT_READ | PROT_WRITE,
+ MapFlags, 0, 0);
if ((intptr_t)FunctionDataCopy == -1)
exit(ChildProcessExitCodeE::FunctionDataMappingFailed);