Skip to content

Commit 2dcf631

Browse files
authored
Merge pull request #9702 from cachemeifyoucan/eng/PR-138555312-release
[Test] Fix Profile-arm64.ContinuousSyncMode.darwin-proof-of-concept.c
2 parents 7c953db + cb72ae8 commit 2dcf631

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

compiler-rt/test/profile/ContinuousSyncMode/darwin-proof-of-concept.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// mode to a new platform, but is not in and of itself a test of the profiling
55
// runtime.
66

7-
// REQUIRES: darwin
7+
// REQUIRES: darwin, target={{arm64.*}}
88

99
// Align counters and data to the maximum expected page size (16K).
1010
// RUN: %clang -g -o %t %s \
@@ -44,8 +44,8 @@ int create_tmpfile(char *path) {
4444
return EXIT_FAILURE;
4545
}
4646

47-
// Write the data first (at offset 0x4000, after the counters).
48-
if (data_len != pwrite(fd, &data, data_len, 0x4000)) {
47+
// Write the data first (at offset 0x1000, after the counters).
48+
if (data_len != pwrite(fd, &data, data_len, cnts_len)) {
4949
perror("write");
5050
return EXIT_FAILURE;
5151
}
@@ -55,8 +55,8 @@ int create_tmpfile(char *path) {
5555
// Requirements (on Darwin):
5656
// - &cnts_start must be page-aligned.
5757
// - The length and offset-into-fd must be page-aligned.
58-
int *counter_map = (int *)mmap(&cnts_start, 0x4000, PROT_READ | PROT_WRITE,
59-
MAP_FIXED | MAP_SHARED, fd, 0);
58+
int *counter_map = (int *)mmap(&cnts_start, cnts_len, PROT_READ | PROT_WRITE,
59+
MAP_FIXED | MAP_SHARED, fd, 0);
6060
if (counter_map != &cnts_start) {
6161
perror("mmap");
6262
return EXIT_FAILURE;
@@ -97,7 +97,7 @@ int validate_tmpfile(char *path) {
9797
}
9898

9999
// Verify that the rest of the counters (after counter 9) are 0.
100-
const int num_cnts = 0x4000 / sizeof(int);
100+
const int num_cnts = cnts_len / sizeof(int);
101101
for (int i = 10; i < num_cnts; ++i) {
102102
if (buf[i] != 0) {
103103
fprintf(stderr,
@@ -131,8 +131,9 @@ int main(int argc, char **argv) {
131131
fprintf(stderr, "__pcnts is not page-aligned: 0x%lx.\n", cnts_start_int);
132132
return EXIT_FAILURE;
133133
}
134-
if (data_start_int % pagesz != 0) {
135-
fprintf(stderr, "__pdata is not page-aligned: 0x%lx.\n", data_start_int);
134+
if (data_start_int % 0x4000 != 0) {
135+
fprintf(stderr, "__pdata is not correctly aligned: 0x%lx.\n",
136+
data_start_int);
136137
return EXIT_FAILURE;
137138
}
138139
if (cnts_start_int + 0x4000 != data_start_int) {

0 commit comments

Comments
 (0)