llvm.org GIT mirror llvm / 69086b2
[msan] Fix handling of select with struct arguments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189796 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 7 years ago
2 changed file(s) with 27 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
17431743 void visitSelectInst(SelectInst& I) {
17441744 IRBuilder<> IRB(&I);
17451745 // a = select b, c, d
1746 // Sa = (sext Sb) | (select b, Sc, Sd)
17471746 Value *S = IRB.CreateSelect(I.getCondition(), getShadow(I.getTrueValue()),
17481747 getShadow(I.getFalseValue()));
1749 Value *S2 = IRB.CreateSExt(getShadow(I.getCondition()), S->getType());
1750 setShadow(&I, IRB.CreateOr(S, S2, "_msprop"));
1748 if (I.getType()->isAggregateType()) {
1749 // To avoid "sign extending" i1 to an arbitrary aggregate type, we just do
1750 // an extra "select". This results in much more compact IR.
1751 // Sa = select Sb, poisoned, (select b, Sc, Sd)
1752 S = IRB.CreateSelect(getShadow(I.getCondition()),
1753 getPoisonedShadow(getShadowTy(I.getType())), S,
1754 "_msprop_select_agg");
1755 } else {
1756 // Sa = (sext Sb) | (select b, Sc, Sd)
1757 S = IRB.CreateOr(
1758 S, IRB.CreateSExt(getShadow(I.getCondition()), S->getType()),
1759 "_msprop_select");
1760 }
1761 setShadow(&I, S);
17511762 if (MS.TrackOrigins) {
17521763 // Origins are always i32, so any vector conditions must be flattened.
17531764 // FIXME: consider tracking vector origins for app vectors?
289289 ; CHECK-ORIGINS: ret <8 x i16>
290290
291291
292 define { i64, i64 } @SelectStruct(i1 zeroext %x, { i64, i64 } %a, { i64, i64 } %b) readnone sanitize_memory {
293 entry:
294 %c = select i1 %x, { i64, i64 } %a, { i64, i64 } %b
295 ret { i64, i64 } %c
296 }
297
298 ; CHECK: @SelectStruct
299 ; CHECK: select i1 {{.*}}, { i64, i64 }
300 ; CHECK-NEXT: select i1 {{.*}}, { i64, i64 } { i64 -1, i64 -1 }, { i64, i64 }
301 ; CHECK-NEXT: select i1 {{.*}}, { i64, i64 }
302 ; CHECK: ret { i64, i64 }
303
304
292305 define i8* @IntToPtr(i64 %x) nounwind uwtable readnone sanitize_memory {
293306 entry:
294307 %0 = inttoptr i64 %x to i8*