@@ -2180,7 +2180,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2180
2180
// /
2181
2181
// / This location will be later instrumented with a check that will print a
2182
2182
// / UMR warning in runtime if the shadow value is not 0.
2183
- void insertShadowCheck (Value *Shadow, Value *Origin, Instruction *OrigIns) {
2183
+ void insertCheckShadow (Value *Shadow, Value *Origin, Instruction *OrigIns) {
2184
2184
assert (Shadow);
2185
2185
if (!InsertChecks)
2186
2186
return ;
@@ -2201,11 +2201,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2201
2201
ShadowOriginAndInsertPoint (Shadow, Origin, OrigIns));
2202
2202
}
2203
2203
2204
- // / Remember the place where a shadow check should be inserted.
2204
+ // / Get shadow for value, and remember the place where a shadow check should
2205
+ // / be inserted.
2205
2206
// /
2206
2207
// / This location will be later instrumented with a check that will print a
2207
2208
// / UMR warning in runtime if the value is not fully defined.
2208
- void insertShadowCheck (Value *Val, Instruction *OrigIns) {
2209
+ void insertCheckShadowOf (Value *Val, Instruction *OrigIns) {
2209
2210
assert (Val);
2210
2211
Value *Shadow, *Origin;
2211
2212
if (ClCheckConstantShadow) {
@@ -2219,7 +2220,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2219
2220
return ;
2220
2221
Origin = dyn_cast_or_null<Instruction>(getOrigin (Val));
2221
2222
}
2222
- insertShadowCheck (Shadow, Origin, OrigIns);
2223
+ insertCheckShadow (Shadow, Origin, OrigIns);
2223
2224
}
2224
2225
2225
2226
AtomicOrdering addReleaseOrdering (AtomicOrdering a) {
@@ -2331,7 +2332,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2331
2332
}
2332
2333
2333
2334
if (ClCheckAccessAddress)
2334
- insertShadowCheck (I.getPointerOperand (), &I);
2335
+ insertCheckShadowOf (I.getPointerOperand (), &I);
2335
2336
2336
2337
if (I.isAtomic ())
2337
2338
I.setOrdering (addAcquireOrdering (I.getOrdering ()));
@@ -2354,7 +2355,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2354
2355
void visitStoreInst (StoreInst &I) {
2355
2356
StoreList.push_back (&I);
2356
2357
if (ClCheckAccessAddress)
2357
- insertShadowCheck (I.getPointerOperand (), &I);
2358
+ insertCheckShadowOf (I.getPointerOperand (), &I);
2358
2359
}
2359
2360
2360
2361
void handleCASOrRMW (Instruction &I) {
@@ -2368,13 +2369,13 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2368
2369
.first ;
2369
2370
2370
2371
if (ClCheckAccessAddress)
2371
- insertShadowCheck (Addr, &I);
2372
+ insertCheckShadowOf (Addr, &I);
2372
2373
2373
2374
// Only test the conditional argument of cmpxchg instruction.
2374
2375
// The other argument can potentially be uninitialized, but we can not
2375
2376
// detect this situation reliably without possible false positives.
2376
2377
if (isa<AtomicCmpXchgInst>(I))
2377
- insertShadowCheck (Val, &I);
2378
+ insertCheckShadowOf (Val, &I);
2378
2379
2379
2380
IRB.CreateStore (getCleanShadow (Val), ShadowPtr);
2380
2381
@@ -2394,15 +2395,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2394
2395
2395
2396
// Vector manipulation.
2396
2397
void visitExtractElementInst (ExtractElementInst &I) {
2397
- insertShadowCheck (I.getOperand (1 ), &I);
2398
+ insertCheckShadowOf (I.getOperand (1 ), &I);
2398
2399
IRBuilder<> IRB (&I);
2399
2400
setShadow (&I, IRB.CreateExtractElement (getShadow (&I, 0 ), I.getOperand (1 ),
2400
2401
" _msprop" ));
2401
2402
setOrigin (&I, getOrigin (&I, 0 ));
2402
2403
}
2403
2404
2404
2405
void visitInsertElementInst (InsertElementInst &I) {
2405
- insertShadowCheck (I.getOperand (2 ), &I);
2406
+ insertCheckShadowOf (I.getOperand (2 ), &I);
2406
2407
IRBuilder<> IRB (&I);
2407
2408
auto *Shadow0 = getShadow (&I, 0 );
2408
2409
auto *Shadow1 = getShadow (&I, 1 );
@@ -2884,7 +2885,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2884
2885
void handleIntegerDiv (Instruction &I) {
2885
2886
IRBuilder<> IRB (&I);
2886
2887
// Strict on the second argument.
2887
- insertShadowCheck (I.getOperand (1 ), &I);
2888
+ insertCheckShadowOf (I.getOperand (1 ), &I);
2888
2889
setShadow (&I, getShadow (&I, 0 ));
2889
2890
setOrigin (&I, getOrigin (&I, 0 ));
2890
2891
}
@@ -3162,7 +3163,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3162
3163
IRB.CreateAlignedStore (Shadow, ShadowPtr, Align (1 ));
3163
3164
3164
3165
if (ClCheckAccessAddress)
3165
- insertShadowCheck (Addr, &I);
3166
+ insertCheckShadowOf (Addr, &I);
3166
3167
3167
3168
// FIXME: factor out common code from materializeStores
3168
3169
if (MS.TrackOrigins )
@@ -3195,7 +3196,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3195
3196
}
3196
3197
3197
3198
if (ClCheckAccessAddress)
3198
- insertShadowCheck (Addr, &I);
3199
+ insertCheckShadowOf (Addr, &I);
3199
3200
3200
3201
if (MS.TrackOrigins ) {
3201
3202
if (PropagateShadow)
@@ -3552,7 +3553,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3552
3553
AggShadow = ConvertShadow;
3553
3554
}
3554
3555
assert (AggShadow->getType ()->isIntegerTy ());
3555
- insertShadowCheck (AggShadow, getOrigin (ConvertOp), &I);
3556
+ insertCheckShadow (AggShadow, getOrigin (ConvertOp), &I);
3556
3557
3557
3558
// Build result shadow by zero-filling parts of CopyOp shadow that come from
3558
3559
// ConvertOp.
@@ -3959,7 +3960,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3959
3960
IRB.CreateStore (getCleanShadow (Ty), ShadowPtr);
3960
3961
3961
3962
if (ClCheckAccessAddress)
3962
- insertShadowCheck (Addr, &I);
3963
+ insertCheckShadowOf (Addr, &I);
3963
3964
}
3964
3965
3965
3966
void handleLdmxcsr (IntrinsicInst &I) {
@@ -3975,12 +3976,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3975
3976
getShadowOriginPtr (Addr, IRB, Ty, Alignment, /* isStore*/ false );
3976
3977
3977
3978
if (ClCheckAccessAddress)
3978
- insertShadowCheck (Addr, &I);
3979
+ insertCheckShadowOf (Addr, &I);
3979
3980
3980
3981
Value *Shadow = IRB.CreateAlignedLoad (Ty, ShadowPtr, Alignment, " _ldmxcsr" );
3981
3982
Value *Origin = MS.TrackOrigins ? IRB.CreateLoad (MS.OriginTy , OriginPtr)
3982
3983
: getCleanOrigin ();
3983
- insertShadowCheck (Shadow, Origin, &I);
3984
+ insertCheckShadow (Shadow, Origin, &I);
3984
3985
}
3985
3986
3986
3987
void handleMaskedExpandLoad (IntrinsicInst &I) {
@@ -3991,8 +3992,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3991
3992
Value *PassThru = I.getArgOperand (2 );
3992
3993
3993
3994
if (ClCheckAccessAddress) {
3994
- insertShadowCheck (Ptr, &I);
3995
- insertShadowCheck (Mask, &I);
3995
+ insertCheckShadowOf (Ptr, &I);
3996
+ insertCheckShadowOf (Mask, &I);
3996
3997
}
3997
3998
3998
3999
if (!PropagateShadow) {
@@ -4024,8 +4025,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4024
4025
Value *Mask = I.getArgOperand (2 );
4025
4026
4026
4027
if (ClCheckAccessAddress) {
4027
- insertShadowCheck (Ptr, &I);
4028
- insertShadowCheck (Mask, &I);
4028
+ insertCheckShadowOf (Ptr, &I);
4029
+ insertCheckShadowOf (Mask, &I);
4029
4030
}
4030
4031
4031
4032
Value *Shadow = getShadow (Values);
@@ -4049,11 +4050,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4049
4050
4050
4051
Type *PtrsShadowTy = getShadowTy (Ptrs);
4051
4052
if (ClCheckAccessAddress) {
4052
- insertShadowCheck (Mask, &I);
4053
+ insertCheckShadowOf (Mask, &I);
4053
4054
Value *MaskedPtrShadow = IRB.CreateSelect (
4054
4055
Mask, getShadow (Ptrs), Constant::getNullValue ((PtrsShadowTy)),
4055
4056
" _msmaskedptrs" );
4056
- insertShadowCheck (MaskedPtrShadow, getOrigin (Ptrs), &I);
4057
+ insertCheckShadow (MaskedPtrShadow, getOrigin (Ptrs), &I);
4057
4058
}
4058
4059
4059
4060
if (!PropagateShadow) {
@@ -4087,11 +4088,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4087
4088
4088
4089
Type *PtrsShadowTy = getShadowTy (Ptrs);
4089
4090
if (ClCheckAccessAddress) {
4090
- insertShadowCheck (Mask, &I);
4091
+ insertCheckShadowOf (Mask, &I);
4091
4092
Value *MaskedPtrShadow = IRB.CreateSelect (
4092
4093
Mask, getShadow (Ptrs), Constant::getNullValue ((PtrsShadowTy)),
4093
4094
" _msmaskedptrs" );
4094
- insertShadowCheck (MaskedPtrShadow, getOrigin (Ptrs), &I);
4095
+ insertCheckShadow (MaskedPtrShadow, getOrigin (Ptrs), &I);
4095
4096
}
4096
4097
4097
4098
Value *Shadow = getShadow (Values);
@@ -4119,8 +4120,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4119
4120
Value *Shadow = getShadow (V);
4120
4121
4121
4122
if (ClCheckAccessAddress) {
4122
- insertShadowCheck (Ptr, &I);
4123
- insertShadowCheck (Mask, &I);
4123
+ insertCheckShadowOf (Ptr, &I);
4124
+ insertCheckShadowOf (Mask, &I);
4124
4125
}
4125
4126
4126
4127
Value *ShadowPtr;
@@ -4152,8 +4153,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4152
4153
Value *PassThru = I.getArgOperand (3 );
4153
4154
4154
4155
if (ClCheckAccessAddress) {
4155
- insertShadowCheck (Ptr, &I);
4156
- insertShadowCheck (Mask, &I);
4156
+ insertCheckShadowOf (Ptr, &I);
4157
+ insertCheckShadowOf (Mask, &I);
4157
4158
}
4158
4159
4159
4160
if (!PropagateShadow) {
@@ -4216,8 +4217,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4216
4217
Value *SrcShadow = getShadow (Src);
4217
4218
4218
4219
if (ClCheckAccessAddress) {
4219
- insertShadowCheck (Dst, &I);
4220
- insertShadowCheck (Mask, &I);
4220
+ insertCheckShadowOf (Dst, &I);
4221
+ insertCheckShadowOf (Mask, &I);
4221
4222
}
4222
4223
4223
4224
Value *DstShadowPtr;
@@ -4277,7 +4278,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4277
4278
const Align Alignment = Align (1 );
4278
4279
4279
4280
if (ClCheckAccessAddress) {
4280
- insertShadowCheck (Mask, &I);
4281
+ insertCheckShadowOf (Mask, &I);
4281
4282
}
4282
4283
4283
4284
Type *SrcShadowTy = getShadowTy (Src);
@@ -4322,7 +4323,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4322
4323
assert (V->getType () == IndexBits->getType ());
4323
4324
V = IRB.CreateOr (V, IRB.CreateAnd (V, IndexBits));
4324
4325
}
4325
- insertShadowCheck (V, getOrigin (Idx), I);
4326
+ insertCheckShadow (V, getOrigin (Idx), I);
4326
4327
}
4327
4328
4328
4329
// Instrument AVX permutation intrinsic.
@@ -4611,8 +4612,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4611
4612
// Technically, we could probably just check whether the LSB is
4612
4613
// initialized, but intuitively it feels like a partly uninitialized mask
4613
4614
// is unintended, and we should warn the user immediately.
4614
- insertShadowCheck (Mask, &I);
4615
- insertShadowCheck (RoundingMode, &I);
4615
+ insertCheckShadowOf (Mask, &I);
4616
+ insertCheckShadowOf (RoundingMode, &I);
4616
4617
4617
4618
assert (isa<FixedVectorType>(A->getType ()));
4618
4619
unsigned NumElements =
@@ -4693,7 +4694,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4693
4694
ShadowArgs.push_back (LaneNumber);
4694
4695
4695
4696
// TODO: blend shadow of lane number into output shadow?
4696
- insertShadowCheck (LaneNumber, &I);
4697
+ insertCheckShadowOf (LaneNumber, &I);
4697
4698
}
4698
4699
4699
4700
Value *Src = I.getArgOperand (numArgs - 1 );
@@ -4745,7 +4746,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4745
4746
int skipTrailingOperands = 1 ;
4746
4747
4747
4748
if (ClCheckAccessAddress)
4748
- insertShadowCheck (Addr, &I);
4749
+ insertCheckShadowOf (Addr, &I);
4749
4750
4750
4751
// Second-last operand is the lane number (for vst{2,3,4}lane)
4751
4752
if (useLane) {
@@ -5720,7 +5721,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
5720
5721
if (A->getType ()->isScalableTy ()) {
5721
5722
LLVM_DEBUG (dbgs () << " Arg " << i << " is vscale: " << CB << " \n " );
5722
5723
// Handle as noundef, but don't reserve tls slots.
5723
- insertShadowCheck (A, &CB);
5724
+ insertCheckShadowOf (A, &CB);
5724
5725
continue ;
5725
5726
}
5726
5727
@@ -5732,7 +5733,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
5732
5733
bool EagerCheck = MayCheckCall && !ByVal && NoUndef;
5733
5734
5734
5735
if (EagerCheck) {
5735
- insertShadowCheck (A, &CB);
5736
+ insertCheckShadowOf (A, &CB);
5736
5737
Size = DL.getTypeAllocSize (A->getType ());
5737
5738
} else {
5738
5739
[[maybe_unused]] Value *Store = nullptr ;
@@ -5880,7 +5881,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
5880
5881
Value *Shadow = getShadow (RetVal);
5881
5882
bool StoreOrigin = true ;
5882
5883
if (EagerCheck) {
5883
- insertShadowCheck (RetVal, &I);
5884
+ insertCheckShadowOf (RetVal, &I);
5884
5885
Shadow = getCleanShadow (RetVal);
5885
5886
StoreOrigin = false ;
5886
5887
}
@@ -6113,7 +6114,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
6113
6114
// Each such pointer is instrumented with a call to the runtime library.
6114
6115
Type *OpType = Operand->getType ();
6115
6116
// Check the operand value itself.
6116
- insertShadowCheck (Operand, &I);
6117
+ insertCheckShadowOf (Operand, &I);
6117
6118
if (!OpType->isPointerTy () || !isOutput) {
6118
6119
assert (!isOutput);
6119
6120
return ;
@@ -6223,7 +6224,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
6223
6224
for (size_t i = 0 , n = I.getNumOperands (); i < n; i++) {
6224
6225
Value *Operand = I.getOperand (i);
6225
6226
if (Operand->getType ()->isSized ())
6226
- insertShadowCheck (Operand, &I);
6227
+ insertCheckShadowOf (Operand, &I);
6227
6228
}
6228
6229
setShadow (&I, getCleanShadow (&I));
6229
6230
setOrigin (&I, getCleanOrigin ());
0 commit comments