[LLVMdev] Update load/store alignments

Mario Schwalbe mario.schwalbe at tu-dresden.de
Mon Dec 16 08:02:13 PST 2013


Hi,

Am 13.12.13 20:34, schrieb John Criswell:
> I believe the alignment constraints on loads and stores are for telling the 
> code generator that it can assume that the load or store accesses a value
> aligned to that boundary (which on some targets can cause the code generator
> to generate better code).  As such, if you change the alignment of a global 
> variable to a larger value, you probably don't need to change the alignments 
> of any loads or stores that may access it.

But unfortunately, I need that because of some following pass, I also wrote myself.

> That said, it looks like the LoadInst and StoreInst classes have a setAlignment()
> method that allows you to set the alignment.  Search for LoadInst and StoreInst
> in the LLVM doxygen documentation.

I know about that. But it also means I have to write such a pass myself, which
isn't that simple given that the pointer operand of loads and stores could also
be a constant expression involving multiple nested GEPs. What's the alignment then?
Therefore, I was wondering if there's already any pass that does so.

In the meantime, I wrote a simple test application and ran opt -O3 -print-after-all
on it. It looks like InstCombine adds and fixes the alignment constraints of
loads and stores.

ciao,
Mario




More information about the llvm-dev mailing list