mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[msan] Fix handling of scalar select of vectors.
llvm-svn: 192575
This commit is contained in:
parent
c460e7e50a
commit
57dafd2630
@ -1233,15 +1233,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
Value *CreateShadowCast(IRBuilder<> &IRB, Value *V, Type *dstTy) {
|
Value *CreateShadowCast(IRBuilder<> &IRB, Value *V, Type *dstTy) {
|
||||||
Type *srcTy = V->getType();
|
Type *srcTy = V->getType();
|
||||||
if (dstTy->isIntegerTy() && srcTy->isIntegerTy())
|
if (dstTy->isIntegerTy() && srcTy->isIntegerTy())
|
||||||
return IRB.CreateIntCast(V, dstTy, false);
|
return IRB.CreateIntCast(V, dstTy, true);
|
||||||
if (dstTy->isVectorTy() && srcTy->isVectorTy() &&
|
if (dstTy->isVectorTy() && srcTy->isVectorTy() &&
|
||||||
dstTy->getVectorNumElements() == srcTy->getVectorNumElements())
|
dstTy->getVectorNumElements() == srcTy->getVectorNumElements())
|
||||||
return IRB.CreateIntCast(V, dstTy, false);
|
return IRB.CreateIntCast(V, dstTy, true);
|
||||||
size_t srcSizeInBits = VectorOrPrimitiveTypeSizeInBits(srcTy);
|
size_t srcSizeInBits = VectorOrPrimitiveTypeSizeInBits(srcTy);
|
||||||
size_t dstSizeInBits = VectorOrPrimitiveTypeSizeInBits(dstTy);
|
size_t dstSizeInBits = VectorOrPrimitiveTypeSizeInBits(dstTy);
|
||||||
Value *V1 = IRB.CreateBitCast(V, Type::getIntNTy(*MS.C, srcSizeInBits));
|
Value *V1 = IRB.CreateBitCast(V, Type::getIntNTy(*MS.C, srcSizeInBits));
|
||||||
Value *V2 =
|
Value *V2 =
|
||||||
IRB.CreateIntCast(V1, Type::getIntNTy(*MS.C, dstSizeInBits), false);
|
IRB.CreateIntCast(V1, Type::getIntNTy(*MS.C, dstSizeInBits), true);
|
||||||
return IRB.CreateBitCast(V2, dstTy);
|
return IRB.CreateBitCast(V2, dstTy);
|
||||||
// TODO: handle struct types.
|
// TODO: handle struct types.
|
||||||
}
|
}
|
||||||
@ -1899,7 +1899,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
} else {
|
} else {
|
||||||
// Sa = (sext Sb) | (select b, Sc, Sd)
|
// Sa = (sext Sb) | (select b, Sc, Sd)
|
||||||
S = IRB.CreateOr(
|
S = IRB.CreateOr(
|
||||||
S, IRB.CreateSExt(getShadow(I.getCondition()), S->getType()),
|
S, CreateShadowCast(IRB, getShadow(I.getCondition()), S->getType()),
|
||||||
"_msprop_select");
|
"_msprop_select");
|
||||||
}
|
}
|
||||||
setShadow(&I, S);
|
setShadow(&I, S);
|
||||||
|
@ -290,6 +290,25 @@ entry:
|
|||||||
; CHECK-ORIGINS: ret <8 x i16>
|
; CHECK-ORIGINS: ret <8 x i16>
|
||||||
|
|
||||||
|
|
||||||
|
; Check that we propagate origin for "select" with scalar condition and vector
|
||||||
|
; arguments. Select condition shadow is sign-extended to the vector type and
|
||||||
|
; mixed into the result shadow.
|
||||||
|
|
||||||
|
define <8 x i16> @SelectVector2(<8 x i16> %a, <8 x i16> %b, i1 %c) nounwind uwtable readnone sanitize_memory {
|
||||||
|
entry:
|
||||||
|
%cond = select i1 %c, <8 x i16> %a, <8 x i16> %b
|
||||||
|
ret <8 x i16> %cond
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK: @SelectVector2
|
||||||
|
; CHECK: select i1
|
||||||
|
; CHECK: sext i1 {{.*}} to i128
|
||||||
|
; CHECK: bitcast i128 {{.*}} to <8 x i16>
|
||||||
|
; CHECK: or <8 x i16>
|
||||||
|
; CHECK: select i1
|
||||||
|
; CHECK: ret <8 x i16>
|
||||||
|
|
||||||
|
|
||||||
define { i64, i64 } @SelectStruct(i1 zeroext %x, { i64, i64 } %a, { i64, i64 } %b) readnone sanitize_memory {
|
define { i64, i64 } @SelectStruct(i1 zeroext %x, { i64, i64 } %a, { i64, i64 } %b) readnone sanitize_memory {
|
||||||
entry:
|
entry:
|
||||||
%c = select i1 %x, { i64, i64 } %a, { i64, i64 } %b
|
%c = select i1 %x, { i64, i64 } %a, { i64, i64 } %b
|
||||||
|
Loading…
x
Reference in New Issue
Block a user