[llvm-dev] Changing Alignment of global variables in LLVM

Matthias Braun via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 3 15:34:19 PDT 2017


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> 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
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list