[llvm-commits] [PATCH] lli memory manager does not ensure proper alignment
Amara Emerson
amara.emerson at gmail.com
Sat Oct 13 12:05:13 PDT 2012
Hi Jim,
That code was replaced by a call to RoundUpToAlignment() in the later
patch in this thread.
Amara
On 12 October 2012 19:35, Jim Grosbach <grosbach at apple.com> wrote:
> + // Honour the alignment requirement.
> + uint8_t *AlignedAddr = Addr;
> + unsigned AlignNeeded = Alignment - ((uintptr_t)Addr % Alignment);
> + if (AlignNeeded != Alignment)
> + AlignedAddr = Addr + AlignNeeded;
>
> Why not just the following?
> AlignedAddr = (uint8_t*)(((uintptr_t)Addr + Alignment - 1) / Alignment *
> Alignment);
>
> On Oct 12, 2012, at 5:36 AM, Amara Emerson <amara.emerson at arm.com> wrote:
>
> Hi,
>
> The allocateDataSection() function in the default lli memory manager does
> not properly align the memory address it receives from calloc in accordance
> with the caller’s requirements. This obviously creates problems as the data
> in the section assumes a certain alignment, causing segfaults on ARM.
>
> Please review the attached patch.
>
> Amara
> <lli-align-datasection.patch>_______________________________________________
>
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list