21
21
#include " llvm/Analysis/GlobalsModRef.h"
22
22
#include " llvm/Analysis/PostDominators.h"
23
23
#include " llvm/Analysis/StackSafetyAnalysis.h"
24
+ #include " llvm/Analysis/TargetLibraryInfo.h"
24
25
#include " llvm/Analysis/ValueTracking.h"
25
26
#include " llvm/BinaryFormat/Dwarf.h"
26
27
#include " llvm/BinaryFormat/ELF.h"
52
53
#include " llvm/TargetParser/Triple.h"
53
54
#include " llvm/Transforms/Instrumentation/AddressSanitizerCommon.h"
54
55
#include " llvm/Transforms/Utils/BasicBlockUtils.h"
56
+ #include " llvm/Transforms/Utils/Local.h"
55
57
#include " llvm/Transforms/Utils/MemoryTaggingSupport.h"
56
58
#include " llvm/Transforms/Utils/ModuleUtils.h"
57
59
#include " llvm/Transforms/Utils/PromoteMemToReg.h"
@@ -320,7 +322,8 @@ class HWAddressSanitizer {
320
322
LoopInfo *LI);
321
323
bool ignoreAccess (Instruction *Inst, Value *Ptr);
322
324
void getInterestingMemoryOperands (
323
- Instruction *I, SmallVectorImpl<InterestingMemoryOperand> &Interesting);
325
+ Instruction *I, const TargetLibraryInfo &TLI,
326
+ SmallVectorImpl<InterestingMemoryOperand> &Interesting);
324
327
325
328
void tagAlloca (IRBuilder<> &IRB, AllocaInst *AI, Value *Tag, size_t Size);
326
329
Value *tagPointer (IRBuilder<> &IRB, Type *Ty, Value *PtrLong, Value *Tag);
@@ -779,7 +782,8 @@ bool HWAddressSanitizer::ignoreAccess(Instruction *Inst, Value *Ptr) {
779
782
}
780
783
781
784
void HWAddressSanitizer::getInterestingMemoryOperands (
782
- Instruction *I, SmallVectorImpl<InterestingMemoryOperand> &Interesting) {
785
+ Instruction *I, const TargetLibraryInfo &TLI,
786
+ SmallVectorImpl<InterestingMemoryOperand> &Interesting) {
783
787
// Skip memory accesses inserted by another instrumentation.
784
788
if (I->hasMetadata (LLVMContext::MD_nosanitize))
785
789
return ;
@@ -817,6 +821,7 @@ void HWAddressSanitizer::getInterestingMemoryOperands(
817
821
Type *Ty = CI->getParamByValType (ArgNo);
818
822
Interesting.emplace_back (I, ArgNo, false , Ty, Align (1 ));
819
823
}
824
+ maybeMarkSanitizerLibraryCallNoBuiltin (CI, &TLI);
820
825
}
821
826
}
822
827
@@ -1493,6 +1498,7 @@ void HWAddressSanitizer::sanitizeFunction(Function &F,
1493
1498
SmallVector<InterestingMemoryOperand, 16 > OperandsToInstrument;
1494
1499
SmallVector<MemIntrinsic *, 16 > IntrinToInstrument;
1495
1500
SmallVector<Instruction *, 8 > LandingPadVec;
1501
+ const TargetLibraryInfo &TLI = FAM.getResult <TargetLibraryAnalysis>(F);
1496
1502
1497
1503
memtag::StackInfoBuilder SIB (SSI);
1498
1504
for (auto &Inst : instructions (F)) {
@@ -1503,7 +1509,7 @@ void HWAddressSanitizer::sanitizeFunction(Function &F,
1503
1509
if (InstrumentLandingPads && isa<LandingPadInst>(Inst))
1504
1510
LandingPadVec.push_back (&Inst);
1505
1511
1506
- getInterestingMemoryOperands (&Inst, OperandsToInstrument);
1512
+ getInterestingMemoryOperands (&Inst, TLI, OperandsToInstrument);
1507
1513
1508
1514
if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(&Inst))
1509
1515
if (!ignoreMemIntrinsic (MI))
0 commit comments