@@ -363,7 +363,7 @@ class HWAddressSanitizer {
363363 Value *getAllocaTag (IRBuilder<> &IRB, Value *StackTag, unsigned AllocaNo);
364364 Value *getUARTag (IRBuilder<> &IRB);
365365
366- Value *getHwasanThreadSlotPtr (IRBuilder<> &IRB, Type *Ty );
366+ Value *getHwasanThreadSlotPtr (IRBuilder<> &IRB);
367367 Value *applyTagMask (IRBuilder<> &IRB, Value *OldTag);
368368 unsigned retagMask (unsigned AllocaNo);
369369
@@ -1219,20 +1219,10 @@ Value *HWAddressSanitizer::untagPointer(IRBuilder<> &IRB, Value *PtrLong) {
12191219 return UntaggedPtrLong;
12201220}
12211221
1222- Value *HWAddressSanitizer::getHwasanThreadSlotPtr (IRBuilder<> &IRB, Type *Ty) {
1223- Module *M = IRB.GetInsertBlock ()->getParent ()->getParent ();
1224- if (TargetTriple.isAArch64 () && TargetTriple.isAndroid ()) {
1225- // Android provides a fixed TLS slot for sanitizers. See TLS_SLOT_SANITIZER
1226- // in Bionic's libc/private/bionic_tls.h.
1227- Function *ThreadPointerFunc =
1228- Intrinsic::getDeclaration (M, Intrinsic::thread_pointer);
1229- return IRB.CreateConstGEP1_32 (Int8Ty, IRB.CreateCall (ThreadPointerFunc),
1230- 0x30 );
1231- }
1232- if (ThreadPtrGlobal)
1233- return ThreadPtrGlobal;
1234-
1235- return nullptr ;
1222+ Value *HWAddressSanitizer::getHwasanThreadSlotPtr (IRBuilder<> &IRB) {
1223+ if (TargetTriple.isAArch64 () && TargetTriple.isAndroid ())
1224+ return memtag::getAndroidSanitizerSlotPtr (IRB);
1225+ return ThreadPtrGlobal;
12361226}
12371227
12381228Value *HWAddressSanitizer::getCachedFP (IRBuilder<> &IRB) {
@@ -1271,7 +1261,7 @@ void HWAddressSanitizer::emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord) {
12711261
12721262 auto getThreadLongMaybeUntagged = [&]() {
12731263 if (!SlotPtr)
1274- SlotPtr = getHwasanThreadSlotPtr (IRB, IntptrTy );
1264+ SlotPtr = getHwasanThreadSlotPtr (IRB);
12751265 if (!ThreadLong)
12761266 ThreadLong = IRB.CreateLoad (IntptrTy, SlotPtr);
12771267 // Extract the address field from ThreadLong. Unnecessary on AArch64 with
0 commit comments