diff options
| author | Emil Tsalapatis <aimilios.tsalapatis@gmail.com> | 2025-11-18 10:58:09 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-18 07:58:09 -0800 |
| commit | a1e47cefa913d53e55d924a6326697f3fe5d1206 (patch) | |
| tree | 12510166618ac0bf0dcd9f7f28d0e7902c5e46ad | |
| parent | 83d27f6c84d92b4450a62f4b650b9cfadc0dab0f (diff) | |
[llvm][AddressSanitizer] option for specifying the address space of the shadow map (#167772)
The AddressSanitizer transform currently defaults to placing the shadow
map in address space 0, but it is desirable for some targets (namely
BPF) to select a different address space for the map. Add a compilation
option for specifying the address space of the target.
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 7c364f86fb0e..49f03fa93f0e 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -248,6 +248,11 @@ static cl::opt<bool> "platforms that support this"), cl::Hidden, cl::init(true)); +static cl::opt<int> + ClShadowAddrSpace("asan-shadow-addr-space", + cl::desc("Address space for pointers to the shadow map"), + cl::Hidden, cl::init(0)); + static cl::opt<bool> ClWithIfuncSuppressRemat( "asan-with-ifunc-suppress-remat", cl::desc("Suppress rematerialization of dynamic shadow address by passing " @@ -1942,7 +1947,7 @@ void AddressSanitizer::instrumentAddress(Instruction *OrigIns, Type *ShadowTy = IntegerType::get(*C, std::max(8U, TypeStoreSize >> Mapping.Scale)); - Type *ShadowPtrTy = PointerType::get(*C, 0); + Type *ShadowPtrTy = PointerType::get(*C, ClShadowAddrSpace); Value *ShadowPtr = memToShadow(AddrLong, IRB); const uint64_t ShadowAlign = std::max<uint64_t>(Alignment.valueOrOne().value() >> Mapping.Scale, 1); |
