This is an archive of the discontinued LLVM Phabricator instance.

[MSAN] Add support for big endian byte order to the test ptrtoint
AbandonedPublic

Authored by slthakur on Feb 11 2016, 9:07 AM.

Details

Reviewers
kcc
eugenis
Summary

Read the poisoned/non-poisoned bytes correctly for big endian targets.

Diff Detail

Repository
rL LLVM

Event Timeline

slthakur updated this revision to Diff 47663.Feb 11 2016, 9:07 AM
slthakur retitled this revision from to [MSAN] Add support for big endian byte order to the test ptrtoint.
slthakur updated this object.
slthakur added reviewers: kcc, eugenis.
slthakur set the repository for this revision to rL LLVM.
slthakur added subscribers: jaydeep, mohit.bhakkad.
slthakur added a subscriber: llvm-commits.
eugenis edited edge metadata.Feb 11 2016, 1:55 PM

Could you check if this works for you:

TEST(MemorySanitizer, ptrtoint) {

// Test that shadow is propagated through pointer-to-integer conversion.                                                      
unsigned char c = 0;
__msan_poison(&c, 1);
uintptr_t u = (uintptr_t)c << 8;
EXPECT_NOT_POISONED(u & 0xFF00FF);
EXPECT_POISONED(u & 0xFF00);

break_optimization(&u);
void* p = (void*)u;

break_optimization(&p);
EXPECT_POISONED(p);
EXPECT_NOT_POISONED(((uintptr_t)p) & 0xFF00FF);
EXPECT_POISONED(((uintptr_t)p) & 0xFF00);

}

Hi @eugenis

This test works for me for both byte orders.

Thanks,
Sagar

slthakur abandoned this revision.Feb 14 2016, 9:48 PM