From a32dbfd28edef3c909856705db8ddc5e3222acdb Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Mon, 16 Feb 2015 15:05:14 +0000 Subject: [msan] Fix UnalignedLoad/UnalignedStore tests. Add alignment attrubutes to ensure that the tests actually test unaligned access irrespective of the stack layout. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229398 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/msan/tests/msan_test.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/msan/tests') diff --git a/lib/msan/tests/msan_test.cc b/lib/msan/tests/msan_test.cc index 5e578ab7c..2aa6ecc20 100644 --- a/lib/msan/tests/msan_test.cc +++ b/lib/msan/tests/msan_test.cc @@ -3522,7 +3522,7 @@ TEST(MemorySanitizer, VolatileBitfield) { } TEST(MemorySanitizer, UnalignedLoad) { - char x[32]; + char x[32] __attribute__((aligned(8))); U4 origin = __LINE__; for (unsigned i = 0; i < sizeof(x) / 4; ++i) __msan_set_origin(x + 4 * i, 4, origin + i); @@ -3556,7 +3556,7 @@ TEST(MemorySanitizer, UnalignedLoad) { } TEST(MemorySanitizer, UnalignedStore16) { - char x[5]; + char x[5] __attribute__((aligned(4))); U2 y2 = 0; U4 origin = __LINE__; __msan_poison(&y2, 1); @@ -3567,11 +3567,10 @@ TEST(MemorySanitizer, UnalignedStore16) { EXPECT_POISONED_O(x[1], origin); EXPECT_NOT_POISONED(x[2]); EXPECT_POISONED_O(x[3], origin); - EXPECT_POISONED_O(x[4], origin); } TEST(MemorySanitizer, UnalignedStore32) { - char x[8]; + char x[8] __attribute__((aligned(4))); U4 y4 = 0; U4 origin = __LINE__; __msan_poison(&y4, 2); @@ -3589,7 +3588,7 @@ TEST(MemorySanitizer, UnalignedStore32) { } TEST(MemorySanitizer, UnalignedStore64) { - char x[16]; + char x[16] __attribute__((aligned(8))); U8 y8 = 0; U4 origin = __LINE__; __msan_poison(&y8, 3); @@ -3612,7 +3611,7 @@ TEST(MemorySanitizer, UnalignedStore64) { } TEST(MemorySanitizer, UnalignedStore16_precise) { - char x[8]; + char x[8] __attribute__((aligned(4))); U2 y = 0; U4 originx1 = __LINE__; U4 originx2 = __LINE__; @@ -3635,7 +3634,7 @@ TEST(MemorySanitizer, UnalignedStore16_precise) { } TEST(MemorySanitizer, UnalignedStore16_precise2) { - char x[8]; + char x[8] __attribute__((aligned(4))); U2 y = 0; U4 originx1 = __LINE__; U4 originx2 = __LINE__; @@ -3658,7 +3657,7 @@ TEST(MemorySanitizer, UnalignedStore16_precise2) { } TEST(MemorySanitizer, UnalignedStore64_precise) { - char x[12]; + char x[12] __attribute__((aligned(8))); U8 y = 0; U4 originx1 = __LINE__; U4 originx2 = __LINE__; @@ -3690,7 +3689,7 @@ TEST(MemorySanitizer, UnalignedStore64_precise) { } TEST(MemorySanitizer, UnalignedStore64_precise2) { - char x[12]; + char x[12] __attribute__((aligned(8))); U8 y = 0; U4 originx1 = __LINE__; U4 originx2 = __LINE__; -- cgit v1.2.3