Skip to content

Commit 9a69de6

Browse files
committed
[msan] Convert vector shadow to scalar before zext
zext does not allow converting vector shadow to scalar, so we must manually convert it prior to calling zext in materializeOneCheck, for which the 'convertedShadow' parameter isn't actually guaranteed to be scalar. In contrast, the storeOrigin function already converts the (potentially vector) shadow to scalar; we add a comment to note that it is load bearing.
1 parent 0fe82ea commit 9a69de6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
12831283
const DataLayout &DL = F.getParent()->getDataLayout();
12841284
const Align OriginAlignment = std::max(kMinOriginAlignment, Alignment);
12851285
TypeSize StoreSize = DL.getTypeStoreSize(Shadow->getType());
1286+
// ZExt cannot convert between vector and scalar
12861287
Value *ConvertedShadow = convertShadowToScalar(Shadow, IRB);
12871288
if (auto *ConstantShadow = dyn_cast<Constant>(ConvertedShadow)) {
12881289
if (!ClCheckConstantShadow || ConstantShadow->isZeroValue()) {
@@ -1398,6 +1399,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
13981399
if (instrumentWithCalls(ConvertedShadow) &&
13991400
SizeIndex < kNumberOfAccessSizes && !MS.CompileKernel) {
14001401
FunctionCallee Fn = MS.MaybeWarningFn[SizeIndex];
1402+
// ZExt cannot convert between vector and scalar
1403+
ConvertedShadow = convertShadowToScalar(ConvertedShadow, IRB);
14011404
Value *ConvertedShadow2 =
14021405
IRB.CreateZExt(ConvertedShadow, IRB.getIntNTy(8 * (1 << SizeIndex)));
14031406
CallBase *CB = IRB.CreateCall(

0 commit comments

Comments
 (0)