diff options
author | Florian Mayer <fmayer@google.com> | 2024-03-14 13:52:22 -0700 |
---|---|---|
committer | Florian Mayer <fmayer@google.com> | 2024-03-14 13:52:22 -0700 |
commit | de96c71240c4c1021d8267cd8ccee4abc9299257 (patch) | |
tree | 760b816086d21ac95261af1c2277984c27d7c145 | |
parent | 2fa147901476434f4133d8e2a1c737ea0367e7b4 (diff) | |
download | llvm-de96c71240c4c1021d8267cd8ccee4abc9299257.zip llvm-de96c71240c4c1021d8267cd8ccee4abc9299257.tar.gz llvm-de96c71240c4c1021d8267cd8ccee4abc9299257.tar.bz2 |
rename
Created using spr 1.3.4
3 files changed, 17 insertions, 19 deletions
diff --git a/llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h b/llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h index cbbb8ff..8c77e5e 100644 --- a/llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h +++ b/llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h @@ -81,7 +81,7 @@ uint64_t getAllocaSizeInBytes(const AllocaInst &AI); void alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Align); Value *readRegister(IRBuilder<> &IRB, StringRef Name); -Value *getSP(IRBuilder<> &IRB); +Value *getFP(IRBuilder<> &IRB); Value *getPC(const Triple &TargetTriple, IRBuilder<> &IRB); } // namespace memtag diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index 58361fc..0c15941 100644 --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -371,7 +371,7 @@ private: void instrumentGlobal(GlobalVariable *GV, uint8_t Tag); void instrumentGlobals(); - Value *getCachedSP(IRBuilder<> &IRB); + Value *getCachedFP(IRBuilder<> &IRB); Value *getFrameRecordInfo(IRBuilder<> &IRB); void instrumentPersonalityFunctions(); @@ -446,7 +446,7 @@ private: Value *ShadowBase = nullptr; Value *StackBaseTag = nullptr; - Value *CachedSP = nullptr; + Value *CachedFP = nullptr; GlobalValue *ThreadPtrGlobal = nullptr; }; @@ -1166,10 +1166,10 @@ Value *HWAddressSanitizer::getStackBaseTag(IRBuilder<> &IRB) { // Extract some entropy from the stack pointer for the tags. // Take bits 20..28 (ASLR entropy) and xor with bits 0..8 (these differ // between functions). - Value *StackPointerLong = getCachedSP(IRB); + Value *FramePointerLong = getCachedFP(IRB); Value *StackTag = - applyTagMask(IRB, IRB.CreateXor(StackPointerLong, - IRB.CreateLShr(StackPointerLong, 20))); + applyTagMask(IRB, IRB.CreateXor(FramePointerLong, + IRB.CreateLShr(FramePointerLong, 20))); StackTag->setName("hwasan.stack.base.tag"); return StackTag; } @@ -1183,9 +1183,9 @@ Value *HWAddressSanitizer::getAllocaTag(IRBuilder<> &IRB, Value *StackTag, } Value *HWAddressSanitizer::getUARTag(IRBuilder<> &IRB) { - Value *StackPointerLong = getCachedSP(IRB); + Value *FramePointerLong = getCachedFP(IRB); Value *UARTag = - applyTagMask(IRB, IRB.CreateLShr(StackPointerLong, PointerTagShift)); + applyTagMask(IRB, IRB.CreateLShr(FramePointerLong, PointerTagShift)); UARTag->setName("hwasan.uar.tag"); return UARTag; @@ -1244,16 +1244,16 @@ Value *HWAddressSanitizer::getHwasanThreadSlotPtr(IRBuilder<> &IRB, Type *Ty) { return nullptr; } -Value *HWAddressSanitizer::getCachedSP(IRBuilder<> &IRB) { - if (!CachedSP) - CachedSP = memtag::getSP(IRB); - return CachedSP; +Value *HWAddressSanitizer::getCachedFP(IRBuilder<> &IRB) { + if (!CachedFP) + CachedFP = memtag::getFP(IRB); + return CachedFP; } Value *HWAddressSanitizer::getFrameRecordInfo(IRBuilder<> &IRB) { // Prepare ring buffer data. Value *PC = memtag::getPC(TargetTriple, IRB); - Value *SP = getCachedSP(IRB); + Value *FP = getCachedFP(IRB); // Mix SP and PC. // Assumptions: @@ -1261,8 +1261,8 @@ Value *HWAddressSanitizer::getFrameRecordInfo(IRBuilder<> &IRB) { // SP is 0xsssssssssssSSSS0 (4 lower bits are zero) // We only really need ~20 lower non-zero bits (SSSS), so we mix like this: // 0xSSSSPPPPPPPPPPPP - SP = IRB.CreateShl(SP, 44); - return IRB.CreateOr(PC, SP); + FP = IRB.CreateShl(FP, 44); + return IRB.CreateOr(PC, FP); } void HWAddressSanitizer::emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord) { @@ -1615,7 +1615,7 @@ void HWAddressSanitizer::sanitizeFunction(Function &F, ShadowBase = nullptr; StackBaseTag = nullptr; - CachedSP = nullptr; + CachedFP = nullptr; } void HWAddressSanitizer::instrumentGlobal(GlobalVariable *GV, uint8_t Tag) { diff --git a/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp b/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp index 8b97a27..14cb965 100644 --- a/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp +++ b/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp @@ -256,9 +256,7 @@ Value *getPC(const Triple &TargetTriple, IRBuilder<> &IRB) { IRB.getIntPtrTy(M->getDataLayout())); } -Value *getSP(IRBuilder<> &IRB) { - // FIXME: use addressofreturnaddress (but implement it in aarch64 backend - // first). +Value *getFP(IRBuilder<> &IRB) { Function *F = IRB.GetInsertBlock()->getParent(); Module *M = F->getParent(); auto *GetStackPointerFn = Intrinsic::getDeclaration( |