This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Improve the uses of roundUpTo/roundDownTo/isAligned
ClosedPublic

Authored by Chia-hungDuan on Jan 26 2023, 12:55 PM.

Details

Summary

The implementations of those functions require the rounding target to be
power-of-two. It's better to add a debugging check to avoid misuse.
Besides, add a general verion of those three to accommadate non
power-of-two cases.

Also change the name to roundUp/roundDown/isAligned

Diff Detail

Event Timeline

Chia-hungDuan created this revision.Jan 26 2023, 12:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 12:55 PM
Chia-hungDuan requested review of this revision.Jan 26 2023, 12:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 12:55 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
cryptoad accepted this revision.Jan 27 2023, 8:34 AM
This revision is now accepted and ready to land.Jan 27 2023, 8:34 AM
cferris added inline comments.Feb 2 2023, 5:21 PM
compiler-rt/lib/scudo/standalone/common.h
36

I put in another change that this name is a bit confusing. Maybe it would be better to rename these as roundUpToBoundary, or maybe just roundUp.

I'm not sure if I'm nitpicking here though, but the Slow versions names are confusing.

address review comments

compiler-rt/lib/scudo/standalone/common.h
36

Per discussion, change the name to roundUp and roundUpSlow

cferris accepted this revision.Feb 10 2023, 2:32 PM

LGTM

This revision was landed with ongoing or failed builds.Feb 15 2023, 3:46 PM
This revision was automatically updated to reflect the committed changes.
enh added a subscriber: enh.Feb 24 2023, 9:34 AM
enh added inline comments.
compiler-rt/lib/scudo/standalone/common.h
32

is there a reason not to use the clang rounding builtins?

Chia-hungDuan added inline comments.Feb 24 2023, 10:27 AM
compiler-rt/lib/scudo/standalone/common.h
32

Good question. Maybe we don't require Scudo to be built with Clang only?

cryptoad added inline comments.Feb 24 2023, 10:30 AM
compiler-rt/lib/scudo/standalone/common.h
32

Scudo must be buildable with GCC for sure, but there are places that specifically check for clang to use some builtins.
While it complicates a bit the readability, it might be worth it.