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
Details
Diff Detail
Diff Detail
Unit Tests
Unit Tests
Event Timeline
| llvm/lib/Analysis/Loads.cpp | ||
|---|---|---|
| 37 | 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. | |
Comment Actions
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. | |
Now that the code is in APInt it's not entirely obvious how the comment is addressed.
Maybe reformulating the comment like so would help : "Delegating alignment check to APInt as Offset and Alignment might have different bit width. e.g., Align is 2^64 but Offset is from a 32 bit Address Space."
Or something along those lines.