@@ -3949,14 +3949,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
39493949 // /
39503950 // / For example, this can be applied to the Arm NEON vector table intrinsics
39513951 // / (tbl{1,2,3,4}).
3952- void handleIntrinsicByApplyingToShadow (IntrinsicInst &I, unsigned int numArgOperands ) {
3952+ void handleIntrinsicByApplyingToShadow (IntrinsicInst &I) {
39533953 IRBuilder<> IRB (&I);
39543954
3955- // Don't use getNumOperands() because it includes the callee
3956- assert (numArgOperands == I.arg_size ());
3957-
39583955 SmallVector<Value *, 8 > ShadowArgs;
3959- for (unsigned int i = 0 ; i < numArgOperands; i++) {
3956+ // Don't use getNumOperands() because it includes the callee
3957+ for (unsigned int i = 0 ; i < I.arg_size (); i++) {
39603958 Value *Shadow = getShadow (&I, i);
39613959 ShadowArgs.append (1 , Shadow);
39623960 }
@@ -4343,22 +4341,24 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
43434341 break ;
43444342 }
43454343
4346- // Arm NEON vector table intrinsics have the source/table register(s),
4347- // followed by the index register. They return the output.
4348- case Intrinsic::aarch64_neon_tbl1: {
4349- handleIntrinsicByApplyingToShadow (I, 2 );
4350- break ;
4351- }
4352- case Intrinsic::aarch64_neon_tbl2: {
4353- handleIntrinsicByApplyingToShadow (I, 3 );
4354- break ;
4355- }
4356- case Intrinsic::aarch64_neon_tbl3: {
4357- handleIntrinsicByApplyingToShadow (I, 4 );
4358- break ;
4359- }
4360- case Intrinsic::aarch64_neon_tbl4: {
4361- handleIntrinsicByApplyingToShadow (I, 5 );
4344+ // Arm NEON vector table intrinsics have the source/table register(s) as,
4345+ // arguments followed by the index register. They return the output.
4346+ //
4347+ // 'TBL writes a zero if an index is out-of-range, while TBX leaves the
4348+ // original value unchanged in the destination register.'
4349+ // Conveniently, zero denotes a clean shadow, which means out-of-range
4350+ // indices for TBL will initialize the user data with zero and also clean
4351+ // the shadow. (For TBX, neither the user data nor the shadow will be
4352+ // updated, which is also correct.)
4353+ case Intrinsic::aarch64_neon_tbl1:
4354+ case Intrinsic::aarch64_neon_tbl2:
4355+ case Intrinsic::aarch64_neon_tbl3:
4356+ case Intrinsic::aarch64_neon_tbl4:
4357+ case Intrinsic::aarch64_neon_tbx1:
4358+ case Intrinsic::aarch64_neon_tbx2:
4359+ case Intrinsic::aarch64_neon_tbx3:
4360+ case Intrinsic::aarch64_neon_tbx4: {
4361+ handleIntrinsicByApplyingToShadow (I);
43624362 break ;
43634363 }
43644364
0 commit comments