Skip to content

Commit a1e47ce

Browse files
authored
[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.
1 parent 83d27f6 commit a1e47ce

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ static cl::opt<bool>
248248
"platforms that support this"),
249249
cl::Hidden, cl::init(true));
250250

251+
static cl::opt<int>
252+
ClShadowAddrSpace("asan-shadow-addr-space",
253+
cl::desc("Address space for pointers to the shadow map"),
254+
cl::Hidden, cl::init(0));
255+
251256
static cl::opt<bool> ClWithIfuncSuppressRemat(
252257
"asan-with-ifunc-suppress-remat",
253258
cl::desc("Suppress rematerialization of dynamic shadow address by passing "
@@ -1942,7 +1947,7 @@ void AddressSanitizer::instrumentAddress(Instruction *OrigIns,
19421947

19431948
Type *ShadowTy =
19441949
IntegerType::get(*C, std::max(8U, TypeStoreSize >> Mapping.Scale));
1945-
Type *ShadowPtrTy = PointerType::get(*C, 0);
1950+
Type *ShadowPtrTy = PointerType::get(*C, ClShadowAddrSpace);
19461951
Value *ShadowPtr = memToShadow(AddrLong, IRB);
19471952
const uint64_t ShadowAlign =
19481953
std::max<uint64_t>(Alignment.valueOrOne().value() >> Mapping.Scale, 1);

0 commit comments

Comments
 (0)