@@ -87,13 +87,13 @@ struct TypeSanitizer {
87
87
88
88
bool instrumentWithShadowUpdate (IRBuilder<> &IRB, const MDNode *TBAAMD,
89
89
Value *Ptr, uint64_t AccessSize, bool IsRead,
90
- bool IsWrite, Value *& ShadowBase,
91
- Value *& AppMemMask, bool ForceSetType,
90
+ bool IsWrite, Value *ShadowBase,
91
+ Value *AppMemMask, bool ForceSetType,
92
92
bool SanitizeFunction,
93
93
TypeDescriptorsMapTy &TypeDescriptors,
94
94
const DataLayout &DL);
95
95
bool instrumentMemoryAccess (Instruction *I, MemoryLocation &MLoc,
96
- Value *& ShadowBase, Value *& AppMemMask,
96
+ Value *ShadowBase, Value *AppMemMask,
97
97
bool SanitizeFunction,
98
98
TypeDescriptorsMapTy &TypeDescriptors,
99
99
const DataLayout &DL);
@@ -170,7 +170,8 @@ void TypeSanitizer::instrumentGlobals(Module &M) {
170
170
ReturnInst::Create (M.getContext (), BB);
171
171
172
172
const DataLayout &DL = M.getDataLayout ();
173
- Value *ShadowBase = nullptr , *AppMemMask = nullptr ;
173
+ Value *ShadowBase = getShadowBase (*TysanGlobalsSetTypeFunction);
174
+ Value *AppMemMask = getAppMemMask (*TysanGlobalsSetTypeFunction);
174
175
TypeDescriptorsMapTy TypeDescriptors;
175
176
TypeNameMapTy TypeNames;
176
177
@@ -551,7 +552,8 @@ bool TypeSanitizer::run(Function &F, const TargetLibraryInfo &TLI) {
551
552
552
553
const DataLayout &DL = F.getParent ()->getDataLayout ();
553
554
bool SanitizeFunction = F.hasFnAttribute (Attribute::SanitizeType);
554
- Value *ShadowBase = nullptr , *AppMemMask = nullptr ;
555
+ Value *ShadowBase = MemoryAccesses.empty () ? nullptr : getShadowBase (F);
556
+ Value *AppMemMask = MemoryAccesses.empty () ? nullptr : getAppMemMask (F);
555
557
for (auto &MA : MemoryAccesses)
556
558
Res |= instrumentMemoryAccess (MA.first , MA.second , ShadowBase, AppMemMask,
557
559
SanitizeFunction, TypeDescriptors, DL);
@@ -575,14 +577,9 @@ static Value *ConvertToShadowDataInt(IRBuilder<> &IRB, Value *Ptr,
575
577
576
578
bool TypeSanitizer::instrumentWithShadowUpdate (
577
579
IRBuilder<> &IRB, const MDNode *TBAAMD, Value *Ptr, uint64_t AccessSize,
578
- bool IsRead, bool IsWrite, Value *& ShadowBase, Value *& AppMemMask,
580
+ bool IsRead, bool IsWrite, Value *ShadowBase, Value *AppMemMask,
579
581
bool ForceSetType, bool SanitizeFunction,
580
582
TypeDescriptorsMapTy &TypeDescriptors, const DataLayout &DL) {
581
- if (!ShadowBase)
582
- ShadowBase = getShadowBase (*IRB.GetInsertBlock ()->getParent ());
583
- if (!AppMemMask)
584
- AppMemMask = getAppMemMask (*IRB.GetInsertBlock ()->getParent ());
585
-
586
583
Constant *TDGV;
587
584
if (TBAAMD)
588
585
TDGV = TypeDescriptors[TBAAMD];
@@ -716,9 +713,9 @@ bool TypeSanitizer::instrumentWithShadowUpdate(
716
713
}
717
714
718
715
bool TypeSanitizer::instrumentMemoryAccess (
719
- Instruction *I, MemoryLocation &MLoc, Value *& ShadowBase,
720
- Value *&AppMemMask, bool SanitizeFunction ,
721
- TypeDescriptorsMapTy &TypeDescriptors, const DataLayout &DL) {
716
+ Instruction *I, MemoryLocation &MLoc, Value *ShadowBase, Value *AppMemMask ,
717
+ bool SanitizeFunction, TypeDescriptorsMapTy &TypeDescriptors ,
718
+ const DataLayout &DL) {
722
719
IRBuilder<> IRB (I);
723
720
assert (MLoc.Size .isPrecise ());
724
721
if (instrumentWithShadowUpdate (
0 commit comments