This is an archive of the discontinued LLVM Phabricator instance.

[MSAN] Fix memcmp_test on MIPS
ClosedPublic

Authored by slthakur on Feb 22 2016, 9:42 PM.

Details

Reviewers
kcc
eugenis
Summary

As per the test the 4th element of both arrays are not initialized and hence will contain garbage values. Memcmp returns the difference between the garbage values of the 4th element which will be different on every run of the test. And since the return value of memcmp is returned from main, we are getting random exit code every time.

Diff Detail

Repository
rL LLVM

Event Timeline

slthakur updated this revision to Diff 48779.Feb 22 2016, 9:42 PM
slthakur retitled this revision from to [MSAN] Fix memcmp_test on MIPS.
slthakur updated this object.
slthakur added reviewers: eugenis, kcc.
slthakur set the repository for this revision to rL LLVM.
slthakur added subscribers: jaydeep, mohit.bhakkad.
eugenis edited edge metadata.Feb 22 2016, 10:04 PM

... which can happen to be zero, right? 1 out of 256.

Please do if (!res) printf("equals") to force the check, then return 0.

... which can happen to be zero, right? 1 out of 256.
Please do if (!res) printf("equals") to force the check, then return 0.

In cases when value of res is not zero, "equals" will not be printed and hence test will fail.
Since the value of res in unpredictable, could we just do return 0 or ignore the exit code?

Yes, that's what I meant. A check for the return value of memcmp so that it is not optimized out (though it probably won't anyway at -O0), and then always return 0.

slthakur updated this revision to Diff 48886.Feb 23 2016, 11:11 PM
slthakur edited edge metadata.

Addressed review comment.

eugenis accepted this revision.Feb 23 2016, 11:17 PM
eugenis edited edge metadata.

LGTM

This revision is now accepted and ready to land.Feb 23 2016, 11:17 PM
slthakur edited edge metadata.Feb 24 2016, 5:50 AM
slthakur added a subscriber: llvm-commits.
slthakur closed this revision.Feb 24 2016, 5:53 AM

Committed in revision 261739