Page MenuHomePhabricator

Prevent -Wcast-align in sha256_shani.cpp
ClosedPublic

Authored by Fabien on May 28 2020, 14:00.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Commits
rABC94dd82f1bc20: Prevent -Wcast-align in sha256_shani.cpp
Summary

Instructions such as _mm_loadu_si128 or _mm_storeu_si128 are
specialized for unaligned access (hence the 'u' suffix). Unfortunately
it triggers a false positive -Wcast-align with Clang.
This diff disables the warnings at the places where it is safe.

Test Plan

With Clang as a compiler (tested with Clang 10), on a platform
supporting the SHA new instructions:

ninja

Check the warning is gone.

Run the Gitian builds.

I ran the benchmark 21 times and compared against master: there is no impact on performance.

Diff Detail

Event Timeline

Fabien requested review of this revision.May 28 2020, 14:00
deadalnix requested changes to this revision.May 28 2020, 14:59
deadalnix added a subscriber: deadalnix.

I think you should create a LoadInteger128Unaligned/StoreInteger128Unaligned an limit the pragma to these functions. Mark the static and always inline and you'll be set.

This revision now requires changes to proceed.May 28 2020, 14:59
Fabien planned changes to this revision.May 28 2020, 19:15

Actually move the cast inside the pragma or it will not help removing the warning...

deadalnix added inline comments.
src/crypto/sha256_shani.cpp
100 ↗(On Diff #20680)

You need to make them static, not inline.

This revision is now accepted and ready to land.May 28 2020, 20:30
This revision was automatically updated to reflect the committed changes.