This is an archive of the discontinued LLVM Phabricator instance.

[Alignment][NFC] Move and type functions from MathExtras to Alignment
ClosedPublic

Authored by gchatelet on Oct 14 2019, 5:22 AM.

Details

Diff Detail

Event Timeline

gchatelet created this revision.Oct 14 2019, 5:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2019, 5:22 AM

Please rename commit to [Alignment][NFC] Move and type functions from MathExtra to Alignment

gchatelet retitled this revision from [Alignment][NFC] Move functions from MathUtils to Alignment to [Alignment][NFC] Move and type functions from MathExtras to Alignment.Oct 14 2019, 5:35 AM
courbet accepted this revision.Oct 14 2019, 5:48 AM
courbet added inline comments.
llvm/unittests/Support/AlignmentTest.cpp
216

Add comment: // A value of any integral or enumeration type can be converted to a pointer type.

I had to check to verify that this was legal.

This revision is now accepted and ready to land.Oct 14 2019, 5:48 AM
gchatelet updated this revision to Diff 224842.Oct 14 2019, 6:11 AM
  • Address comments
This revision was automatically updated to reflect the committed changes.
hans added a subscriber: hans.Oct 17 2019, 2:00 AM
hans added inline comments.
llvm/include/llvm/Support/Alignment.h
176

Because Alignment.value() is a uint64_t, this won't catch overflows when addresses are 32 bits.

This breaks the AlignmentDeathTest.AlignAddr test on 32-bit Windows, for example. And also here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/10957

Hopefully r375090 fixes this, but maybe it would be better for Alignment::value() not to be 64-bit for example.

gchatelet added inline comments.Oct 17 2019, 2:26 AM
llvm/include/llvm/Support/Alignment.h
176

Thx for reporting this and for fixing it @hans.