[llvm-dev] Changing Alignment of global variables in LLVM
Matthias Braun via llvm-dev
llvm-dev at lists.llvm.org
Tue Oct 3 15:41:11 PDT 2017
> On Oct 3, 2017, at 3:39 PM, Charith Mendis <char.mendis1989 at gmail.com> wrote:
>
> If I know for sure I am accessing 32 byte chunks at a time, how can I go about changing the alignment of @u?
>
> Should I use DataLayout's reset method? I couldn't find a method to change alignment of one global variable.
GlobalObject::setAlignment()?
- Matthias
>
> Thanks
>
> On Tue, Oct 3, 2017 at 6:34 PM, Matthias Braun <mbraun at apple.com <mailto:mbraun at apple.com>> wrote:
> The effective alignment is part of the load and store operations. Updating those would mean that you need to know which ones are based on the @u address.
>
> You can come up with some heuristics that track values through getelementptr and similar constructs in llvm IR and which will work in most cases.
>
> However as you can have arbitrary computations to create the address for a load/store tracking the source of such computations is actually undecidable in general and you may have cases where you cannot determine the origin when allowing arbitrary IR.
> Because of this I'd recommend to rather adjust the frontends type system so the loads and stores are created with the correct alignment in the first place.
>
> - Matthias
>
> > On Oct 3, 2017, at 3:25 PM, Charith Mendis via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
> >
> >
> > What is the best way to change the alignment of global variables and allocated structures in LLVM during one of its optimization passes?
> >
> >
> > For example, I want to change,
> >
> > @u = internal unnamed_addr global [5 x [65 x [65 x [65 x double]]]] zeroinitializer, align 16
> >
> > to align to 32 bytes.
> >
> > How can this be accomplished so that all other references in the code accessing this structure are also updated.
> >
> > Thank You
> >
> > --
> > Kind regards,
> > Charith Mendis
> >
> > Graduate Student,
> > CSAIL,
> > Massachusetts Institute of Technology
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
>
>
>
>
> --
> Kind regards,
> Charith Mendis
>
> Graduate Student,
> CSAIL,
> Massachusetts Institute of Technology
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171003/97ffaaf2/attachment.html>
More information about the llvm-dev
mailing list