Hi all, although I feel like this is a too simple question, I can't find the answer right now. I have a pass that changes the alignment constraints of global variables of a module, which doesn't affect any loads and stores of them. So how do I get the loads' and stores' alignment constraints also updated to match my changes? Is there any pass that does so? Ideally without changing too much in the module? Thanks in advance, Mario
On 12/13/13 4:00 AM, Mario Schwalbe wrote:> Hi all, > > although I feel like this is a too simple question, I can't find the answer > right now. > > I have a pass that changes the alignment constraints of global variables > of a module, which doesn't affect any loads and stores of them. So how > do I get the loads' and stores' alignment constraints also updated to > match my changes? Is there any pass that does so? Ideally without changing > too much in the module?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. 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. -- John T.> > Thanks in advance, > Mario > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
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