[llvm-commits] [PATCH] lli memory manager does not ensure proper alignment

Tim Northover t.p.northover at gmail.com
Fri Oct 12 05:56:33 PDT 2012


Hi Amara,

> Please review the attached patch.

There's a function "RoundUpToAlignment" in the llvm namespace which
should probably be used instead of the custom code.

Also, I think the amount calculation is dodgy. Suppose Size=1 and
Alignment=16. It would then ask for 16 bytes. But if a misaligned
address was returned, it would align it up to the end of the block and
use incorrect memory for the single byte.

I *think* the calculation you want (assuming you keep using calloc
like this) is "1 + (Size + Alignment - 1) / Alignment".

Tim.



More information about the llvm-commits mailing list