-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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 all 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 |
---|---|---|
|
@@ -4173,7 +4173,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { | |
|
||
// Instrument AVX permutation intrinsic. | ||
// We apply the same permutation (argument index 1) to the shadow. | ||
void handleAVXVpermilvar(IntrinsicInst &I) { | ||
void handleAVXPermutation(IntrinsicInst &I) { | ||
assert(I.arg_size() == 2); | ||
assert(isa<FixedVectorType>(I.getArgOperand(0)->getType())); | ||
assert(isa<FixedVectorType>(I.getArgOperand(1)->getType())); | ||
[[maybe_unused]] auto ArgVectorSize = | ||
cast<FixedVectorType>(I.getArgOperand(0)->getType())->getNumElements(); | ||
assert(cast<FixedVectorType>(I.getArgOperand(1)->getType()) | ||
->getNumElements() == ArgVectorSize); | ||
assert(I.getType() == I.getArgOperand(0)->getType()); | ||
IRBuilder<> IRB(&I); | ||
Value *Shadow = getShadow(&I, 0); | ||
insertShadowCheck(I.getArgOperand(1), &I); | ||
|
@@ -4187,6 +4195,38 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { | |
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) { | ||
assert(I.arg_size() == 3); | ||
assert(isa<FixedVectorType>(I.getArgOperand(0)->getType())); | ||
assert(isa<FixedVectorType>(I.getArgOperand(1)->getType())); | ||
assert(isa<FixedVectorType>(I.getArgOperand(2)->getType())); | ||
[[maybe_unused]] auto ArgVectorSize = | ||
cast<FixedVectorType>(I.getArgOperand(0)->getType())->getNumElements(); | ||
assert(cast<FixedVectorType>(I.getArgOperand(1)->getType()) | ||
->getNumElements() == ArgVectorSize); | ||
assert(cast<FixedVectorType>(I.getArgOperand(2)->getType()) | ||
->getNumElements() == ArgVectorSize); | ||
assert(I.getArgOperand(0)->getType() == I.getArgOperand(2)->getType()); | ||
assert(I.getType() == I.getArgOperand(0)->getType()); | ||
assert(I.getArgOperand(1)->getType()->isIntOrIntVectorTy()); | ||
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) | ||
|
@@ -5132,16 +5172,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: | ||
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: { | ||
handleAVXVpermilvar(I); | ||
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.