Skip to content

Commit 3830c93

Browse files
committed
tsan: rename kAppMemBeg to kLoAppMemBeg
Unify Go mapping naming with C++ naming to allow writing portable code/tests that can work for both C++ and Go. No functional changes. Depends on D107737. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D107738
1 parent fda121a commit 3830c93

File tree

2 files changed

+22
-42
lines changed

2 files changed

+22
-42
lines changed

compiler-rt/lib/tsan/rtl/tsan_platform.h

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ struct MappingGo48 {
386386
static const uptr kTraceMemEnd = 0x620000000000ull;
387387
static const uptr kShadowBeg = 0x200000000000ull;
388388
static const uptr kShadowEnd = 0x238000000000ull;
389-
static const uptr kAppMemBeg = 0x000000001000ull;
390-
static const uptr kAppMemEnd = 0x00e000000000ull;
389+
static const uptr kLoAppMemBeg = 0x000000001000ull;
390+
static const uptr kLoAppMemEnd = 0x00e000000000ull;
391391
};
392392

393393
/* Go on windows
@@ -409,8 +409,8 @@ struct MappingGoWindows {
409409
static const uptr kTraceMemEnd = 0x076000000000ull;
410410
static const uptr kShadowBeg = 0x010000000000ull;
411411
static const uptr kShadowEnd = 0x050000000000ull;
412-
static const uptr kAppMemBeg = 0x000000001000ull;
413-
static const uptr kAppMemEnd = 0x00e000000000ull;
412+
static const uptr kLoAppMemBeg = 0x000000001000ull;
413+
static const uptr kLoAppMemEnd = 0x00e000000000ull;
414414
};
415415

416416
/* Go on linux/powerpc64 (46-bit VMA)
@@ -433,8 +433,8 @@ struct MappingGoPPC64_46 {
433433
static const uptr kTraceMemEnd = 0x380000000000ull;
434434
static const uptr kShadowBeg = 0x200000000000ull;
435435
static const uptr kShadowEnd = 0x238000000000ull;
436-
static const uptr kAppMemBeg = 0x000000001000ull;
437-
static const uptr kAppMemEnd = 0x00e000000000ull;
436+
static const uptr kLoAppMemBeg = 0x000000001000ull;
437+
static const uptr kLoAppMemEnd = 0x00e000000000ull;
438438
};
439439

440440
/* Go on linux/powerpc64 (47-bit VMA)
@@ -457,8 +457,8 @@ struct MappingGoPPC64_47 {
457457
static const uptr kTraceMemEnd = 0x620000000000ull;
458458
static const uptr kShadowBeg = 0x200000000000ull;
459459
static const uptr kShadowEnd = 0x300000000000ull;
460-
static const uptr kAppMemBeg = 0x000000001000ull;
461-
static const uptr kAppMemEnd = 0x00e000000000ull;
460+
static const uptr kLoAppMemBeg = 0x000000001000ull;
461+
static const uptr kLoAppMemEnd = 0x00e000000000ull;
462462
};
463463

464464
/* Go on linux/aarch64 (48-bit VMA) and darwin/aarch64 (47-bit VMA)
@@ -480,8 +480,8 @@ struct MappingGoAarch64 {
480480
static const uptr kTraceMemEnd = 0x620000000000ull;
481481
static const uptr kShadowBeg = 0x200000000000ull;
482482
static const uptr kShadowEnd = 0x300000000000ull;
483-
static const uptr kAppMemBeg = 0x000000001000ull;
484-
static const uptr kAppMemEnd = 0x00e000000000ull;
483+
static const uptr kLoAppMemBeg = 0x000000001000ull;
484+
static const uptr kLoAppMemEnd = 0x00e000000000ull;
485485
};
486486

487487
/*
@@ -504,8 +504,8 @@ struct MappingGoMips64_47 {
504504
static const uptr kTraceMemEnd = 0x620000000000ull;
505505
static const uptr kShadowBeg = 0x200000000000ull;
506506
static const uptr kShadowEnd = 0x300000000000ull;
507-
static const uptr kAppMemBeg = 0x000000001000ull;
508-
static const uptr kAppMemEnd = 0x00e000000000ull;
507+
static const uptr kLoAppMemBeg = 0x000000001000ull;
508+
static const uptr kLoAppMemEnd = 0x00e000000000ull;
509509
};
510510

511511
/*
@@ -525,8 +525,8 @@ struct MappingGoS390x {
525525
static const uptr kTraceMemEnd = 0xb00000000000ull;
526526
static const uptr kShadowBeg = 0x400000000000ull;
527527
static const uptr kShadowEnd = 0x800000000000ull;
528-
static const uptr kAppMemBeg = 0x000000001000ull;
529-
static const uptr kAppMemEnd = 0x100000000000ull;
528+
static const uptr kLoAppMemBeg = 0x000000001000ull;
529+
static const uptr kLoAppMemEnd = 0x100000000000ull;
530530
};
531531

532532
#if defined(__x86_64__)
@@ -654,8 +654,6 @@ enum MappingType {
654654
MAPPING_MID_APP_END,
655655
MAPPING_HEAP_BEG,
656656
MAPPING_HEAP_END,
657-
MAPPING_APP_BEG,
658-
MAPPING_APP_END,
659657
MAPPING_SHADOW_BEG,
660658
MAPPING_SHADOW_END,
661659
MAPPING_META_SHADOW_BEG,
@@ -669,19 +667,16 @@ struct MappingField {
669667
template <typename Mapping>
670668
static uptr Apply(MappingType type) {
671669
switch (type) {
672-
#if !SANITIZER_GO
673670
case MAPPING_LO_APP_BEG: return Mapping::kLoAppMemBeg;
674671
case MAPPING_LO_APP_END: return Mapping::kLoAppMemEnd;
672+
#if !SANITIZER_GO
675673
case MAPPING_MID_APP_BEG: return Mapping::kMidAppMemBeg;
676674
case MAPPING_MID_APP_END: return Mapping::kMidAppMemEnd;
677675
case MAPPING_HI_APP_BEG: return Mapping::kHiAppMemBeg;
678676
case MAPPING_HI_APP_END: return Mapping::kHiAppMemEnd;
679677
case MAPPING_HEAP_BEG: return Mapping::kHeapMemBeg;
680678
case MAPPING_HEAP_END: return Mapping::kHeapMemEnd;
681679
case MAPPING_VDSO_BEG: return Mapping::kVdsoBeg;
682-
#else
683-
case MAPPING_APP_BEG: return Mapping::kAppMemBeg;
684-
case MAPPING_APP_END: return Mapping::kAppMemEnd;
685680
#endif
686681
case MAPPING_SHADOW_BEG: return Mapping::kShadowBeg;
687682
case MAPPING_SHADOW_END: return Mapping::kShadowEnd;
@@ -696,7 +691,6 @@ struct MappingField {
696691
}
697692
};
698693

699-
#if !SANITIZER_GO
700694
ALWAYS_INLINE
701695
uptr LoAppMemBeg(void) {
702696
return SelectMapping<MappingField>(MAPPING_LO_APP_BEG);
@@ -706,6 +700,7 @@ uptr LoAppMemEnd(void) {
706700
return SelectMapping<MappingField>(MAPPING_LO_APP_END);
707701
}
708702

703+
#if !SANITIZER_GO
709704
ALWAYS_INLINE
710705
uptr MidAppMemBeg(void) {
711706
return SelectMapping<MappingField>(MAPPING_MID_APP_BEG);
@@ -732,23 +727,16 @@ uptr HiAppMemEnd(void) {
732727
ALWAYS_INLINE
733728
uptr VdsoBeg(void) { return SelectMapping<MappingField>(MAPPING_VDSO_BEG); }
734729

735-
#else
736-
737-
ALWAYS_INLINE
738-
uptr AppMemBeg(void) { return SelectMapping<MappingField>(MAPPING_APP_BEG); }
739-
ALWAYS_INLINE
740-
uptr AppMemEnd(void) { return SelectMapping<MappingField>(MAPPING_APP_END); }
741-
742730
#endif
743731

744732
static inline
745733
bool GetUserRegion(int i, uptr *start, uptr *end) {
746734
switch (i) {
747-
#if !SANITIZER_GO
748735
case 0:
749736
*start = LoAppMemBeg();
750737
*end = LoAppMemEnd();
751738
return true;
739+
#if !SANITIZER_GO
752740
case 1:
753741
*start = HiAppMemBeg();
754742
*end = HiAppMemEnd();
@@ -764,11 +752,6 @@ bool GetUserRegion(int i, uptr *start, uptr *end) {
764752
return true;
765753
}
766754
FALLTHROUGH;
767-
#else
768-
case 0:
769-
*start = AppMemBeg();
770-
*end = AppMemEnd();
771-
return true;
772755
#endif
773756
default:
774757
return false;
@@ -807,7 +790,7 @@ struct IsAppMemImpl {
807790
(mem >= Mapping::kLoAppMemBeg && mem < Mapping::kLoAppMemEnd) ||
808791
(mem >= Mapping::kHiAppMemBeg && mem < Mapping::kHiAppMemEnd);
809792
#else
810-
return mem >= Mapping::kAppMemBeg && mem < Mapping::kAppMemEnd;
793+
return mem >= Mapping::kLoAppMemBeg && mem < Mapping::kLoAppMemEnd;
811794
#endif
812795
}
813796
};

compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,14 @@ void FillProfileCallback(uptr p, uptr rss, bool file,
109109
mem[MemShadow] += rss;
110110
else if (p >= MetaShadowBeg() && p < MetaShadowEnd())
111111
mem[MemMeta] += rss;
112-
#if !SANITIZER_GO
113-
else if (p >= HeapMemBeg() && p < HeapMemEnd())
114-
mem[MemHeap] += rss;
115112
else if (p >= LoAppMemBeg() && p < LoAppMemEnd())
116113
mem[file ? MemFile : MemMmap] += rss;
114+
# if !SANITIZER_GO
117115
else if (p >= HiAppMemBeg() && p < HiAppMemEnd())
118116
mem[file ? MemFile : MemMmap] += rss;
119-
#else
120-
else if (p >= AppMemBeg() && p < AppMemEnd())
121-
mem[file ? MemFile : MemMmap] += rss;
122-
#endif
117+
else if (p >= HeapMemBeg() && p < HeapMemEnd())
118+
mem[MemHeap] += rss;
119+
# endif
123120
else if (p >= TraceMemBeg() && p < TraceMemEnd())
124121
mem[MemTrace] += rss;
125122
else

0 commit comments

Comments
 (0)