llvm.org GIT mirror llvm / 967a946
[msan] Fix handling of equality comparison of pointer vectors. Also improve test coveration of the handling of relational comparisons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172539 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 6 years ago
2 changed file(s) with 79 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
573573 if (IntegerType *IT = dyn_cast(OrigTy))
574574 return IT;
575575 if (VectorType *VT = dyn_cast(OrigTy)) {
576 uint32_t EltSize = MS.TD->getTypeStoreSizeInBits(VT->getElementType());
576 uint32_t EltSize = MS.TD->getTypeSizeInBits(VT->getElementType());
577577 return VectorType::get(IntegerType::get(*MS.C, EltSize),
578578 VT->getNumElements());
579579 }
585585 DEBUG(dbgs() << "getShadowTy: " << *ST << " ===> " << *Res << "\n");
586586 return Res;
587587 }
588 uint32_t TypeSize = MS.TD->getTypeStoreSizeInBits(OrigTy);
588 uint32_t TypeSize = MS.TD->getTypeSizeInBits(OrigTy);
589589 return IntegerType::get(*MS.C, TypeSize);
590590 }
591591
11261126 Value *B = I.getOperand(1);
11271127 Value *Sa = getShadow(A);
11281128 Value *Sb = getShadow(B);
1129 if (A->getType()->isPointerTy())
1130 A = IRB.CreatePointerCast(A, MS.IntptrTy);
1131 if (B->getType()->isPointerTy())
1132 B = IRB.CreatePointerCast(B, MS.IntptrTy);
1129
1130 // Get rid of pointers and vectors of pointers.
1131 // For ints (and vectors of ints), types of A and Sa match,
1132 // and this is a no-op.
1133 A = IRB.CreatePointerCast(A, Sa->getType());
1134 B = IRB.CreatePointerCast(B, Sb->getType());
1135
11331136 // A == B <==> (C = A^B) == 0
11341137 // A != B <==> (C = A^B) != 0
11351138 // Sc = Sa | Sb
361361 ; CHECK: ret i1
362362
363363
364 ; Check that we propagate shadow for x<0, x>=0, etc (i.e. sign bit tests)
365 ; of the vector arguments.
366
367 define <2 x i1> @ICmpSLT_vector(<2 x i32*> %x) nounwind uwtable readnone {
368 %1 = icmp slt <2 x i32*> %x, zeroinitializer
369 ret <2 x i1> %1
370 }
371
372 ; CHECK: @ICmpSLT_vector
373 ; CHECK: icmp slt <2 x i64>
374 ; CHECK-NOT: call void @__msan_warning
375 ; CHECK: icmp slt <2 x i32*>
376 ; CHECK-NOT: call void @__msan_warning
377 ; CHECK: ret <2 x i1>
378
379
380 ; Check that we propagate shadow for x == y comparison.
381 ; This is a bit complex. See the comment in handleEqualityComparison.
382
383 define i1 @ICmpEQ(i32 %x, i32 %y) nounwind uwtable readnone {
384 %1 = icmp eq i32 %x, %y
385 ret i1 %1
386 }
387
388 ; CHECK: @ICmpEQ
389 ; CHECK: xor i32 %x, %y
390 ; CHECK: or i32
391 ; CHECK: xor i32
392 ; CHECK: and i32
393 ; CHECK: icmp eq i32
394 ; CHECK: icmp ne i32
395 ; CHECK: and i1
396 ; CHECK: icmp eq i32 %x, %y
397 ; CHECK: ret i1
398
399 define <2 x i1> @ICmpEQ_vector(<2 x i32> %x, <2 x i32> %y) nounwind uwtable readnone {
400 %1 = icmp eq <2 x i32> %x, %y
401 ret <2 x i1> %1
402 }
403
404 ; CHECK: @ICmpEQ_vector
405 ; CHECK: xor <2 x i32> %x, %y
406 ; CHECK: or <2 x i32>
407 ; CHECK: xor <2 x i32>
408 ; CHECK: and <2 x i32>
409 ; CHECK: icmp eq <2 x i32>
410 ; CHECK: icmp ne <2 x i32>
411 ; CHECK: and <2 x i1>
412 ; CHECK: icmp eq <2 x i32> %x, %y
413 ; CHECK: ret <2 x i1>
414
415 define <2 x i1> @ICmpEQ_pointer_vector(<2 x i32*> %x, <2 x i32*> %y) nounwind uwtable readnone {
416 %1 = icmp eq <2 x i32*> %x, %y
417 ret <2 x i1> %1
418 }
419
420 ; CHECK: @ICmpEQ_pointer_vector
421 ; CHECK: ptrtoint <2 x i32*> %x to <2 x i64>
422 ; CHECK: ptrtoint <2 x i32*> %y to <2 x i64>
423 ; CHECK: xor <2 x i64>
424 ; CHECK: or <2 x i64>
425 ; CHECK: xor <2 x i64>
426 ; CHECK: and <2 x i64>
427 ; CHECK: icmp eq <2 x i64>
428 ; CHECK: icmp ne <2 x i64>
429 ; CHECK: and <2 x i1>
430 ; CHECK: icmp eq <2 x i32*> %x, %y
431 ; CHECK: ret <2 x i1>
432
433
364434 ; Check that loads of shadow have the same aligment as the original loads.
365435 ; Check that loads of origin have the aligment of max(4, original alignment).
366436