Skip to content

Commit 4021d30

Browse files
abner-chencsophie-zhao
authored andcommitted
[tsan] Add support for linux/loongarch64 in lib/tsan/go/buildgo.sh (llvm#72819)
Co-authored-by: Xiaolin Zhao <[email protected]> (cherry picked from commit 9d3fbf9) Change-Id: I2adc6314373337f3d87d3bffbb2357c991e95cf2
1 parent b26071a commit 4021d30

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

compiler-rt/lib/tsan/go/buildgo.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if [ "`uname -a | grep Linux`" != "" ]; then
1010
HOST_GOARCH="amd64"
1111
elif [ "`uname -a | grep aarch64`" != "" ]; then
1212
HOST_GOARCH="arm64"
13+
elif [ "`uname -a | grep loongarch64`" != "" ]; then
14+
HOST_GOARCH="loong64"
1315
elif [ "`uname -a | grep -i mips64`" != "" ]; then
1416
if [ "`lscpu | grep -i Little`" != "" ]; then
1517
HOST_GOARCH="mips64le"

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,35 @@ struct MappingGoAarch64 {
558558
static const uptr kShadowAdd = 0x200000000000ull;
559559
};
560560

561+
/* Go on linux/loongarch64 (47-bit VMA)
562+
0000 0000 1000 - 0000 1000 0000: executable
563+
0000 1000 0000 - 00c0 0000 0000: -
564+
00c0 0000 0000 - 00e0 0000 0000: heap
565+
00e0 0000 0000 - 2000 0000 0000: -
566+
2000 0000 0000 - 2800 0000 0000: shadow
567+
2800 0000 0000 - 3000 0000 0000: -
568+
3000 0000 0000 - 3200 0000 0000: metainfo (memory blocks and sync objects)
569+
3200 0000 0000 - 8000 0000 0000: -
570+
*/
571+
struct MappingGoLoongArch64_47 {
572+
static const uptr kMetaShadowBeg = 0x300000000000ull;
573+
static const uptr kMetaShadowEnd = 0x320000000000ull;
574+
static const uptr kShadowBeg = 0x200000000000ull;
575+
static const uptr kShadowEnd = 0x280000000000ull;
576+
static const uptr kLoAppMemBeg = 0x000000001000ull;
577+
static const uptr kLoAppMemEnd = 0x00e000000000ull;
578+
static const uptr kMidAppMemBeg = 0;
579+
static const uptr kMidAppMemEnd = 0;
580+
static const uptr kHiAppMemBeg = 0;
581+
static const uptr kHiAppMemEnd = 0;
582+
static const uptr kHeapMemBeg = 0;
583+
static const uptr kHeapMemEnd = 0;
584+
static const uptr kVdsoBeg = 0;
585+
static const uptr kShadowMsk = 0;
586+
static const uptr kShadowXor = 0;
587+
static const uptr kShadowAdd = 0x200000000000ull;
588+
};
589+
561590
/*
562591
Go on linux/mips64 (47-bit VMA)
563592
0000 0000 1000 - 0000 1000 0000: executable
@@ -633,6 +662,8 @@ ALWAYS_INLINE auto SelectMapping(Arg arg) {
633662
return Func::template Apply<MappingGoS390x>(arg);
634663
# elif defined(__aarch64__)
635664
return Func::template Apply<MappingGoAarch64>(arg);
665+
# elif defined(__loongarch_lp64)
666+
return Func::template Apply<MappingGoLoongArch64_47>(arg);
636667
# elif SANITIZER_WINDOWS
637668
return Func::template Apply<MappingGoWindows>(arg);
638669
# else
@@ -692,6 +723,7 @@ void ForEachMapping() {
692723
Func::template Apply<MappingGoPPC64_46>();
693724
Func::template Apply<MappingGoPPC64_47>();
694725
Func::template Apply<MappingGoAarch64>();
726+
Func::template Apply<MappingGoLoongArch64_47>();
695727
Func::template Apply<MappingGoMips64_47>();
696728
Func::template Apply<MappingGoS390x>();
697729
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,13 @@ void InitializePlatformEarly() {
238238
Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
239239
Die();
240240
}
241-
# endif
241+
# else
242+
if (vmaSize != 47) {
243+
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
244+
Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
245+
Die();
246+
}
247+
# endif
242248
#elif defined(__powerpc64__)
243249
# if !SANITIZER_GO
244250
if (vmaSize != 44 && vmaSize != 46 && vmaSize != 47) {

0 commit comments

Comments
 (0)