@@ -2180,7 +2180,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
21802180 // /
21812181 // / This location will be later instrumented with a check that will print a
21822182 // / 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) {
21842184 assert (Shadow);
21852185 if (!InsertChecks)
21862186 return ;
@@ -2201,11 +2201,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
22012201 ShadowOriginAndInsertPoint (Shadow, Origin, OrigIns));
22022202 }
22032203
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.
22052206 // /
22062207 // / This location will be later instrumented with a check that will print a
22072208 // / 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) {
22092210 assert (Val);
22102211 Value *Shadow, *Origin;
22112212 if (ClCheckConstantShadow) {
@@ -2219,7 +2220,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
22192220 return ;
22202221 Origin = dyn_cast_or_null<Instruction>(getOrigin (Val));
22212222 }
2222- insertShadowCheck (Shadow, Origin, OrigIns);
2223+ insertCheckShadow (Shadow, Origin, OrigIns);
22232224 }
22242225
22252226 AtomicOrdering addReleaseOrdering (AtomicOrdering a) {
@@ -2331,7 +2332,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
23312332 }
23322333
23332334 if (ClCheckAccessAddress)
2334- insertShadowCheck (I.getPointerOperand (), &I);
2335+ insertCheckShadowOf (I.getPointerOperand (), &I);
23352336
23362337 if (I.isAtomic ())
23372338 I.setOrdering (addAcquireOrdering (I.getOrdering ()));
@@ -2354,7 +2355,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
23542355 void visitStoreInst (StoreInst &I) {
23552356 StoreList.push_back (&I);
23562357 if (ClCheckAccessAddress)
2357- insertShadowCheck (I.getPointerOperand (), &I);
2358+ insertCheckShadowOf (I.getPointerOperand (), &I);
23582359 }
23592360
23602361 void handleCASOrRMW (Instruction &I) {
@@ -2368,13 +2369,13 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
23682369 .first ;
23692370
23702371 if (ClCheckAccessAddress)
2371- insertShadowCheck (Addr, &I);
2372+ insertCheckShadowOf (Addr, &I);
23722373
23732374 // Only test the conditional argument of cmpxchg instruction.
23742375 // The other argument can potentially be uninitialized, but we can not
23752376 // detect this situation reliably without possible false positives.
23762377 if (isa<AtomicCmpXchgInst>(I))
2377- insertShadowCheck (Val, &I);
2378+ insertCheckShadowOf (Val, &I);
23782379
23792380 IRB.CreateStore (getCleanShadow (Val), ShadowPtr);
23802381
@@ -2394,15 +2395,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
23942395
23952396 // Vector manipulation.
23962397 void visitExtractElementInst (ExtractElementInst &I) {
2397- insertShadowCheck (I.getOperand (1 ), &I);
2398+ insertCheckShadowOf (I.getOperand (1 ), &I);
23982399 IRBuilder<> IRB (&I);
23992400 setShadow (&I, IRB.CreateExtractElement (getShadow (&I, 0 ), I.getOperand (1 ),
24002401 " _msprop" ));
24012402 setOrigin (&I, getOrigin (&I, 0 ));
24022403 }
24032404
24042405 void visitInsertElementInst (InsertElementInst &I) {
2405- insertShadowCheck (I.getOperand (2 ), &I);
2406+ insertCheckShadowOf (I.getOperand (2 ), &I);
24062407 IRBuilder<> IRB (&I);
24072408 auto *Shadow0 = getShadow (&I, 0 );
24082409 auto *Shadow1 = getShadow (&I, 1 );
@@ -2884,7 +2885,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
28842885 void handleIntegerDiv (Instruction &I) {
28852886 IRBuilder<> IRB (&I);
28862887 // Strict on the second argument.
2887- insertShadowCheck (I.getOperand (1 ), &I);
2888+ insertCheckShadowOf (I.getOperand (1 ), &I);
28882889 setShadow (&I, getShadow (&I, 0 ));
28892890 setOrigin (&I, getOrigin (&I, 0 ));
28902891 }
@@ -3162,7 +3163,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
31623163 IRB.CreateAlignedStore (Shadow, ShadowPtr, Align (1 ));
31633164
31643165 if (ClCheckAccessAddress)
3165- insertShadowCheck (Addr, &I);
3166+ insertCheckShadowOf (Addr, &I);
31663167
31673168 // FIXME: factor out common code from materializeStores
31683169 if (MS.TrackOrigins )
@@ -3195,7 +3196,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
31953196 }
31963197
31973198 if (ClCheckAccessAddress)
3198- insertShadowCheck (Addr, &I);
3199+ insertCheckShadowOf (Addr, &I);
31993200
32003201 if (MS.TrackOrigins ) {
32013202 if (PropagateShadow)
@@ -3552,7 +3553,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
35523553 AggShadow = ConvertShadow;
35533554 }
35543555 assert (AggShadow->getType ()->isIntegerTy ());
3555- insertShadowCheck (AggShadow, getOrigin (ConvertOp), &I);
3556+ insertCheckShadow (AggShadow, getOrigin (ConvertOp), &I);
35563557
35573558 // Build result shadow by zero-filling parts of CopyOp shadow that come from
35583559 // ConvertOp.
@@ -3959,7 +3960,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
39593960 IRB.CreateStore (getCleanShadow (Ty), ShadowPtr);
39603961
39613962 if (ClCheckAccessAddress)
3962- insertShadowCheck (Addr, &I);
3963+ insertCheckShadowOf (Addr, &I);
39633964 }
39643965
39653966 void handleLdmxcsr (IntrinsicInst &I) {
@@ -3975,12 +3976,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
39753976 getShadowOriginPtr (Addr, IRB, Ty, Alignment, /* isStore*/ false );
39763977
39773978 if (ClCheckAccessAddress)
3978- insertShadowCheck (Addr, &I);
3979+ insertCheckShadowOf (Addr, &I);
39793980
39803981 Value *Shadow = IRB.CreateAlignedLoad (Ty, ShadowPtr, Alignment, " _ldmxcsr" );
39813982 Value *Origin = MS.TrackOrigins ? IRB.CreateLoad (MS.OriginTy , OriginPtr)
39823983 : getCleanOrigin ();
3983- insertShadowCheck (Shadow, Origin, &I);
3984+ insertCheckShadow (Shadow, Origin, &I);
39843985 }
39853986
39863987 void handleMaskedExpandLoad (IntrinsicInst &I) {
@@ -3991,8 +3992,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
39913992 Value *PassThru = I.getArgOperand (2 );
39923993
39933994 if (ClCheckAccessAddress) {
3994- insertShadowCheck (Ptr, &I);
3995- insertShadowCheck (Mask, &I);
3995+ insertCheckShadowOf (Ptr, &I);
3996+ insertCheckShadowOf (Mask, &I);
39963997 }
39973998
39983999 if (!PropagateShadow) {
@@ -4024,8 +4025,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
40244025 Value *Mask = I.getArgOperand (2 );
40254026
40264027 if (ClCheckAccessAddress) {
4027- insertShadowCheck (Ptr, &I);
4028- insertShadowCheck (Mask, &I);
4028+ insertCheckShadowOf (Ptr, &I);
4029+ insertCheckShadowOf (Mask, &I);
40294030 }
40304031
40314032 Value *Shadow = getShadow (Values);
@@ -4049,11 +4050,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
40494050
40504051 Type *PtrsShadowTy = getShadowTy (Ptrs);
40514052 if (ClCheckAccessAddress) {
4052- insertShadowCheck (Mask, &I);
4053+ insertCheckShadowOf (Mask, &I);
40534054 Value *MaskedPtrShadow = IRB.CreateSelect (
40544055 Mask, getShadow (Ptrs), Constant::getNullValue ((PtrsShadowTy)),
40554056 " _msmaskedptrs" );
4056- insertShadowCheck (MaskedPtrShadow, getOrigin (Ptrs), &I);
4057+ insertCheckShadow (MaskedPtrShadow, getOrigin (Ptrs), &I);
40574058 }
40584059
40594060 if (!PropagateShadow) {
@@ -4087,11 +4088,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
40874088
40884089 Type *PtrsShadowTy = getShadowTy (Ptrs);
40894090 if (ClCheckAccessAddress) {
4090- insertShadowCheck (Mask, &I);
4091+ insertCheckShadowOf (Mask, &I);
40914092 Value *MaskedPtrShadow = IRB.CreateSelect (
40924093 Mask, getShadow (Ptrs), Constant::getNullValue ((PtrsShadowTy)),
40934094 " _msmaskedptrs" );
4094- insertShadowCheck (MaskedPtrShadow, getOrigin (Ptrs), &I);
4095+ insertCheckShadow (MaskedPtrShadow, getOrigin (Ptrs), &I);
40954096 }
40964097
40974098 Value *Shadow = getShadow (Values);
@@ -4119,8 +4120,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
41194120 Value *Shadow = getShadow (V);
41204121
41214122 if (ClCheckAccessAddress) {
4122- insertShadowCheck (Ptr, &I);
4123- insertShadowCheck (Mask, &I);
4123+ insertCheckShadowOf (Ptr, &I);
4124+ insertCheckShadowOf (Mask, &I);
41244125 }
41254126
41264127 Value *ShadowPtr;
@@ -4152,8 +4153,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
41524153 Value *PassThru = I.getArgOperand (3 );
41534154
41544155 if (ClCheckAccessAddress) {
4155- insertShadowCheck (Ptr, &I);
4156- insertShadowCheck (Mask, &I);
4156+ insertCheckShadowOf (Ptr, &I);
4157+ insertCheckShadowOf (Mask, &I);
41574158 }
41584159
41594160 if (!PropagateShadow) {
@@ -4216,8 +4217,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
42164217 Value *SrcShadow = getShadow (Src);
42174218
42184219 if (ClCheckAccessAddress) {
4219- insertShadowCheck (Dst, &I);
4220- insertShadowCheck (Mask, &I);
4220+ insertCheckShadowOf (Dst, &I);
4221+ insertCheckShadowOf (Mask, &I);
42214222 }
42224223
42234224 Value *DstShadowPtr;
@@ -4277,7 +4278,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
42774278 const Align Alignment = Align (1 );
42784279
42794280 if (ClCheckAccessAddress) {
4280- insertShadowCheck (Mask, &I);
4281+ insertCheckShadowOf (Mask, &I);
42814282 }
42824283
42834284 Type *SrcShadowTy = getShadowTy (Src);
@@ -4322,7 +4323,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
43224323 assert (V->getType () == IndexBits->getType ());
43234324 V = IRB.CreateOr (V, IRB.CreateAnd (V, IndexBits));
43244325 }
4325- insertShadowCheck (V, getOrigin (Idx), I);
4326+ insertCheckShadow (V, getOrigin (Idx), I);
43264327 }
43274328
43284329 // Instrument AVX permutation intrinsic.
@@ -4611,8 +4612,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
46114612 // Technically, we could probably just check whether the LSB is
46124613 // initialized, but intuitively it feels like a partly uninitialized mask
46134614 // 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);
46164617
46174618 assert (isa<FixedVectorType>(A->getType ()));
46184619 unsigned NumElements =
@@ -4693,7 +4694,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
46934694 ShadowArgs.push_back (LaneNumber);
46944695
46954696 // TODO: blend shadow of lane number into output shadow?
4696- insertShadowCheck (LaneNumber, &I);
4697+ insertCheckShadowOf (LaneNumber, &I);
46974698 }
46984699
46994700 Value *Src = I.getArgOperand (numArgs - 1 );
@@ -4745,7 +4746,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
47454746 int skipTrailingOperands = 1 ;
47464747
47474748 if (ClCheckAccessAddress)
4748- insertShadowCheck (Addr, &I);
4749+ insertCheckShadowOf (Addr, &I);
47494750
47504751 // Second-last operand is the lane number (for vst{2,3,4}lane)
47514752 if (useLane) {
@@ -5720,7 +5721,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
57205721 if (A->getType ()->isScalableTy ()) {
57215722 LLVM_DEBUG (dbgs () << " Arg " << i << " is vscale: " << CB << " \n " );
57225723 // Handle as noundef, but don't reserve tls slots.
5723- insertShadowCheck (A, &CB);
5724+ insertCheckShadowOf (A, &CB);
57245725 continue ;
57255726 }
57265727
@@ -5732,7 +5733,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
57325733 bool EagerCheck = MayCheckCall && !ByVal && NoUndef;
57335734
57345735 if (EagerCheck) {
5735- insertShadowCheck (A, &CB);
5736+ insertCheckShadowOf (A, &CB);
57365737 Size = DL.getTypeAllocSize (A->getType ());
57375738 } else {
57385739 [[maybe_unused]] Value *Store = nullptr ;
@@ -5880,7 +5881,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
58805881 Value *Shadow = getShadow (RetVal);
58815882 bool StoreOrigin = true ;
58825883 if (EagerCheck) {
5883- insertShadowCheck (RetVal, &I);
5884+ insertCheckShadowOf (RetVal, &I);
58845885 Shadow = getCleanShadow (RetVal);
58855886 StoreOrigin = false ;
58865887 }
@@ -6113,7 +6114,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
61136114 // Each such pointer is instrumented with a call to the runtime library.
61146115 Type *OpType = Operand->getType ();
61156116 // Check the operand value itself.
6116- insertShadowCheck (Operand, &I);
6117+ insertCheckShadowOf (Operand, &I);
61176118 if (!OpType->isPointerTy () || !isOutput) {
61186119 assert (!isOutput);
61196120 return ;
@@ -6223,7 +6224,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
62236224 for (size_t i = 0 , n = I.getNumOperands (); i < n; i++) {
62246225 Value *Operand = I.getOperand (i);
62256226 if (Operand->getType ()->isSized ())
6226- insertShadowCheck (Operand, &I);
6227+ insertCheckShadowOf (Operand, &I);
62276228 }
62286229 setShadow (&I, getCleanShadow (&I));
62296230 setOrigin (&I, getCleanOrigin ());
0 commit comments