[NFC] pull retvec logic to MemoryTaggingSupport.

we will also need this for aarch64 stack tagging.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D118852
This commit is contained in:
Florian Mayer 2022-02-02 15:28:14 -08:00
parent d6fdbbcace
commit fa75a62cb5
3 changed files with 19 additions and 8 deletions

View File

@ -12,6 +12,7 @@
#ifndef LLVM_TRANSFORMS_UTILS_MEMORYTAGGINGSUPPORT_H
#define LLVM_TRANSFORMS_UTILS_MEMORYTAGGINGSUPPORT_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/IR/Dominators.h"
@ -68,6 +69,9 @@ bool forAllReachableExits(const DominatorTree &DT, const PostDominatorTree &PDT,
bool isStandardLifetime(const SmallVectorImpl<IntrinsicInst *> &LifetimeStart,
const SmallVectorImpl<IntrinsicInst *> &LifetimeEnd,
const DominatorTree *DT, size_t MaxLifetimes);
Instruction *getUntagLocationIfFunctionExit(Instruction &Inst);
} // namespace llvm
#endif

View File

@ -1511,14 +1511,9 @@ bool HWAddressSanitizer::sanitizeFunction(
}
}
if (isa<ReturnInst>(Inst)) {
if (CallInst *CI = Inst.getParent()->getTerminatingMustTailCall())
RetVec.push_back(CI);
else
RetVec.push_back(&Inst);
} else if (isa<ResumeInst, CleanupReturnInst>(Inst)) {
RetVec.push_back(&Inst);
}
Instruction *ExitUntag = getUntagLocationIfFunctionExit(Inst);
if (ExitUntag)
RetVec.push_back(ExitUntag);
if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&Inst)) {
for (Value *V : DVI->location_ops()) {

View File

@ -42,4 +42,16 @@ bool isStandardLifetime(const SmallVectorImpl<IntrinsicInst *> &LifetimeStart,
(LifetimeEnd.size() > 0 &&
!maybeReachableFromEachOther(LifetimeEnd, DT, MaxLifetimes)));
}
Instruction *getUntagLocationIfFunctionExit(Instruction &Inst) {
if (isa<ReturnInst>(Inst)) {
if (CallInst *CI = Inst.getParent()->getTerminatingMustTailCall())
return CI;
return &Inst;
}
if (isa<ResumeInst, CleanupReturnInst>(Inst)) {
return &Inst;
}
return nullptr;
}
} // namespace llvm