Apparently the maximum alignment no longer fits in 32-bits now, which
overflows a 32-bit offset and would fail on the isPowerOf2 assert.
Details
Diff Detail
Event Timeline
llvm/lib/Analysis/Loads.cpp | ||
---|---|---|
33 | How about the following code: static bool isAligned(const Value *Base, const APInt &Offset, Align Alignment, const DataLayout &DL) { Align BA = Base->getPointerAlignment(DL); if (BA < Alignment) return false; const unsigned OffsetTrailingZeroes = Offset.countr_zero(); const unsigned MinimumTrailingZeroes = Log2(Alignment); return OffsetTrailingZeroes >= MinimumTrailingZeroes; } FYI Log2(Alignment) is free. |
Actually, it should be return OffsetTrailingZeroes >= MinimumTrailingZeroes || Offset.isZero(); because zero is always aligned to whatever power of two.
It probably makes sense to add a helper function in Alignment.h. I'll take care of it.
llvm/lib/Analysis/Loads.cpp | ||
---|---|---|
34–35 | Now that the code is in APInt it's not entirely obvious how the comment is addressed. |
How about the following code:
FYI Log2(Alignment) is free.