Skip to content

Commit a566f05

Browse files
[RISCV][ASAN] instrumentation pass now uses proper shadow offset
[10/11] patch series to port ASAN for riscv64 Depends On D87580 Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D87581
1 parent 1113fbf commit a566f05

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ static const uint64_t kSystemZ_ShadowOffset64 = 1ULL << 52;
105105
static const uint64_t kMIPS32_ShadowOffset32 = 0x0aaa0000;
106106
static const uint64_t kMIPS64_ShadowOffset64 = 1ULL << 37;
107107
static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36;
108+
static const uint64_t kRISCV64_ShadowOffset64 = 0x20000000;
108109
static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30;
109110
static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46;
110111
static const uint64_t kNetBSD_ShadowOffset32 = 1ULL << 30;
@@ -447,6 +448,7 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
447448
bool IsMIPS64 = TargetTriple.isMIPS64();
448449
bool IsArmOrThumb = TargetTriple.isARM() || TargetTriple.isThumb();
449450
bool IsAArch64 = TargetTriple.getArch() == Triple::aarch64;
451+
bool IsRISCV64 = TargetTriple.getArch() == Triple::riscv64;
450452
bool IsWindows = TargetTriple.isOSWindows();
451453
bool IsFuchsia = TargetTriple.isOSFuchsia();
452454
bool IsMyriad = TargetTriple.getVendor() == llvm::Triple::Myriad;
@@ -515,6 +517,8 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
515517
Mapping.Offset = kDynamicShadowSentinel;
516518
else if (IsAArch64)
517519
Mapping.Offset = kAArch64_ShadowOffset64;
520+
else if (IsRISCV64)
521+
Mapping.Offset = kRISCV64_ShadowOffset64;
518522
else
519523
Mapping.Offset = kDefaultShadowOffset64;
520524
}
@@ -533,6 +537,7 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
533537
// we could OR the constant in a single instruction, but it's more
534538
// efficient to load it once and use indexed addressing.
535539
Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ && !IsPS4CPU &&
540+
!IsRISCV64 &&
536541
!(Mapping.Offset & (Mapping.Offset - 1)) &&
537542
Mapping.Offset != kDynamicShadowSentinel;
538543
bool IsAndroidWithIfuncSupport =

0 commit comments

Comments
 (0)