@@ -3949,14 +3949,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3949
3949
// /
3950
3950
// / For example, this can be applied to the Arm NEON vector table intrinsics
3951
3951
// / (tbl{1,2,3,4}).
3952
- void handleIntrinsicByApplyingToShadow (IntrinsicInst &I, unsigned int numArgOperands ) {
3952
+ void handleIntrinsicByApplyingToShadow (IntrinsicInst &I) {
3953
3953
IRBuilder<> IRB (&I);
3954
3954
3955
- // Don't use getNumOperands() because it includes the callee
3956
- assert (numArgOperands == I.arg_size ());
3957
-
3958
3955
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++) {
3960
3958
Value *Shadow = getShadow (&I, i);
3961
3959
ShadowArgs.append (1 , Shadow);
3962
3960
}
@@ -4343,22 +4341,24 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4343
4341
break ;
4344
4342
}
4345
4343
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);
4362
4362
break ;
4363
4363
}
4364
4364
0 commit comments