-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[MSAN] handle assorted AVX permutations #143462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
488825c
1a61661
d3892e2
72ad77d
89d9434
7f6e567
b8071ac
e8815be
e7f58f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4159,6 +4159,42 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { | |
| setOrigin(&I, PtrSrcOrigin); | ||
| } | ||
|
|
||
| // Instrument AVX permutation intrinsic. | ||
| // We apply the same permutation (argument index 1) to the shadow. | ||
| void handleAVXPermutation(IntrinsicInst &I) { | ||
| IRBuilder<> IRB(&I); | ||
| Value *Shadow = getShadow(&I, 0); | ||
| insertShadowCheck(I.getArgOperand(1), &I); | ||
|
|
||
| // Shadows are integer-ish types but some intrinsics require a | ||
| // different (e.g., floating-point) type. | ||
| Shadow = IRB.CreateBitCast(Shadow, I.getArgOperand(0)->getType()); | ||
| CallInst *CI = IRB.CreateIntrinsic(I.getType(), I.getIntrinsicID(), | ||
| {Shadow, I.getArgOperand(1)}); | ||
|
|
||
| setShadow(&I, IRB.CreateBitCast(CI, getShadowTy(&I))); | ||
| setOriginForNaryOp(I); | ||
| } | ||
| // Instrument AVX permutation intrinsic. | ||
| // We apply the same permutation (argument index 1) to the shadows. | ||
| void handleAVXVpermil2var(IntrinsicInst &I) { | ||
| IRBuilder<> IRB(&I); | ||
| Value *AShadow = getShadow(&I, 0); | ||
| Value *Idx = I.getArgOperand(1); | ||
| Value *BShadow = getShadow(&I, 2); | ||
| insertShadowCheck(Idx, &I); | ||
|
|
||
| // Shadows are integer-ish types but some intrinsics require a | ||
| // different (e.g., floating-point) type. | ||
| AShadow = IRB.CreateBitCast(AShadow, I.getArgOperand(0)->getType()); | ||
| BShadow = IRB.CreateBitCast(BShadow, I.getArgOperand(2)->getType()); | ||
| CallInst *CI = IRB.CreateIntrinsic(I.getType(), I.getIntrinsicID(), | ||
| {AShadow, Idx, BShadow}); | ||
|
|
||
| setShadow(&I, IRB.CreateBitCast(CI, getShadowTy(&I))); | ||
| setOriginForNaryOp(I); | ||
| } | ||
|
|
||
| // Instrument BMI / BMI2 intrinsics. | ||
| // All of these intrinsics are Z = I(X, Y) | ||
| // where the types of all operands and the result match, and are either i32 or | ||
|
|
@@ -5103,6 +5139,52 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { | |
| assert(Success); | ||
| break; | ||
| } | ||
| case Intrinsic::x86_avx2_permd: | ||
| case Intrinsic::x86_avx2_permps: | ||
| case Intrinsic::x86_ssse3_pshuf_b_128: | ||
| case Intrinsic::x86_avx2_pshuf_b: | ||
| case Intrinsic::x86_avx512_pshuf_b_512: | ||
| case Intrinsic::x86_avx512_permvar_df_256: | ||
| case Intrinsic::x86_avx512_permvar_df_512: | ||
| case Intrinsic::x86_avx512_permvar_di_256: | ||
| case Intrinsic::x86_avx512_permvar_di_512: | ||
| case Intrinsic::x86_avx512_permvar_hi_128: | ||
| case Intrinsic::x86_avx512_permvar_hi_256: | ||
| case Intrinsic::x86_avx512_permvar_hi_512: | ||
| case Intrinsic::x86_avx512_permvar_qi_128: | ||
| case Intrinsic::x86_avx512_permvar_qi_256: | ||
| case Intrinsic::x86_avx512_permvar_qi_512: | ||
| case Intrinsic::x86_avx512_permvar_sf_512: | ||
| case Intrinsic::x86_avx512_permvar_si_512: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please precommit tests to cover all these instructions. |
||
| case Intrinsic::x86_avx_vpermilvar_pd: | ||
| case Intrinsic::x86_avx_vpermilvar_pd_256: | ||
| case Intrinsic::x86_avx512_vpermilvar_pd_512: | ||
| case Intrinsic::x86_avx_vpermilvar_ps: | ||
| case Intrinsic::x86_avx_vpermilvar_ps_256: | ||
| case Intrinsic::x86_avx512_vpermilvar_ps_512: { | ||
| handleAVXPermutation(I); | ||
| break; | ||
| } | ||
| case Intrinsic::x86_avx512_vpermi2var_d_128: | ||
| case Intrinsic::x86_avx512_vpermi2var_d_256: | ||
| case Intrinsic::x86_avx512_vpermi2var_d_512: | ||
| case Intrinsic::x86_avx512_vpermi2var_hi_128: | ||
| case Intrinsic::x86_avx512_vpermi2var_hi_256: | ||
| case Intrinsic::x86_avx512_vpermi2var_hi_512: | ||
| case Intrinsic::x86_avx512_vpermi2var_pd_128: | ||
| case Intrinsic::x86_avx512_vpermi2var_pd_256: | ||
| case Intrinsic::x86_avx512_vpermi2var_pd_512: | ||
| case Intrinsic::x86_avx512_vpermi2var_ps_128: | ||
| case Intrinsic::x86_avx512_vpermi2var_ps_256: | ||
| case Intrinsic::x86_avx512_vpermi2var_ps_512: | ||
| case Intrinsic::x86_avx512_vpermi2var_q_128: | ||
| case Intrinsic::x86_avx512_vpermi2var_q_256: | ||
| case Intrinsic::x86_avx512_vpermi2var_q_512: | ||
| case Intrinsic::x86_avx512_vpermi2var_qi_128: | ||
| case Intrinsic::x86_avx512_vpermi2var_qi_256: | ||
| case Intrinsic::x86_avx512_vpermi2var_qi_512: | ||
| handleAVXVpermil2var(I); | ||
| break; | ||
|
|
||
| case Intrinsic::x86_avx512fp16_mask_add_sh_round: | ||
| case Intrinsic::x86_avx512fp16_mask_sub_sh_round: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.