Xinfinity
2011-Mar-01 10:10 UTC
[LLVMdev] metadata to inform the optimizers that some code should stay unchanged
Hello LLVM, I am working on some passes that perform code transformations. Since I am interested in performance, I apply the O3 passes, right after my pass. However, the optimization passes modify the code inserted by my pass in an undesirable way. As far I know, there is no way to prevent the optimizers from optimizing some regions of code. So what I intend to do is to attach metadata to the instructions contained in basicblocks that I want to remain unchanged, and to modify some of the optimization passes to be aware of the metadata. For now, I am interested only in passes that would affect the control flow graph, so for a start I modify the Simplify CFG pass and the jump threading pass, but I will check which other passes might duplicate the code, merge blocks etc. Do you think the performance will drop significantly if some regions of code are not optimized ? And do you consider this modification would be of any use to the community? Thank you. Alexandra -- View this message in context: http://old.nabble.com/metadata-to-inform-the-optimizers-that-some-code-should-stay-unchanged-tp31039471p31039471.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Devang Patel
2011-Mar-01 18:44 UTC
[LLVMdev] metadata to inform the optimizers that some code should stay unchanged
On Mar 1, 2011, at 2:10 AM, Xinfinity wrote:> > > Hello LLVM, > > I am working on some passes that perform code transformations. Since I am > interested in performance, I apply the O3 passes, right after my pass. > However, the optimization passes modify the code inserted by my pass in an > undesirable way. As far I know, there is no way to prevent the optimizers > from optimizing some regions of code. So what I intend to do is to attach > metadata to the instructions contained in basicblocks that I want to remain > unchanged, and to modify some of the optimization passes to be aware of the > metadata.IMO, this is not the right way to go.> For now, I am interested only in passes that would affect the > control flow graph, so for a start I modify the Simplify CFG pass and the > jump threading pass, but I will check which other passes might duplicate the > code, merge blocks etc. > > Do you think the performance will drop significantly if some regions of code > are not optimized ? > And do you consider this modification would be of any > use to the community? > > Thank you. > Alexandra > > -- > View this message in context: http://old.nabble.com/metadata-to-inform-the-optimizers-that-some-code-should-stay-unchanged-tp31039471p31039471.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Nick Lewycky
2011-Mar-04 05:43 UTC
[LLVMdev] metadata to inform the optimizers that some code should stay unchanged
Xinfinity wrote:> > > Hello LLVM, > > I am working on some passes that perform code transformations. Since I am > interested in performance, I apply the O3 passes, right after my pass. > However, the optimization passes modify the code inserted by my pass in an > undesirable way. As far I know, there is no way to prevent the optimizers > from optimizing some regions of code. So what I intend to do is to attach > metadata to the instructions contained in basicblocks that I want to remain > unchanged, and to modify some of the optimization passes to be aware of the > metadata.Please don't. Metadata is the wrong tool for anything where the metadata can't be discarded and correctness maintained. Is there any reason you can't run opt -O3 first and your pass second? What is your pass actually doing and why does running the optimizations break it? Nick For now, I am interested only in passes that would affect the> control flow graph, so for a start I modify the Simplify CFG pass and the > jump threading pass, but I will check which other passes might duplicate the > code, merge blocks etc. > > Do you think the performance will drop significantly if some regions of code > are not optimized ? And do you consider this modification would be of any > use to the community? > > Thank you. > Alexandra >
Xinfinity
2011-Mar-04 09:33 UTC
[LLVMdev] metadata to inform the optimizers that some code should stay unchanged
Nick Lewycky wrote:> > Xinfinity wrote: >> >> >> Hello LLVM, >> >> I am working on some passes that perform code transformations. Since I am >> interested in performance, I apply the O3 passes, right after my pass. >> However, the optimization passes modify the code inserted by my pass in >> an >> undesirable way. As far I know, there is no way to prevent the optimizers >> from optimizing some regions of code. So what I intend to do is to attach >> metadata to the instructions contained in basicblocks that I want to >> remain >> unchanged, and to modify some of the optimization passes to be aware of >> the >> metadata. > > Please don't. Metadata is the wrong tool for anything where the metadata > can't be discarded and correctness maintained. > > Is there any reason you can't run opt -O3 first and your pass second? > What is your pass actually doing and why does running the optimizations > break it? > > Nick > >You are right, changing the optimizers is not a good idea, I will modify my pass to make it O3 friendly. If I run opt -O3 first and my pas after, there is a significant drop of performance. I use my pass to create multiple versions of regions of code and to insert a selection mechanism that communicates with a runtime system. Callbacks to the runtime system must be patched and they are inserted as inline asm to have a fixed structure and size. O3 changes the position of the inline asm or duplicates them. But it is better to work more on my pass, than to change all optimization passes in LLVM. Thanks. Alexandra -- View this message in context: http://old.nabble.com/metadata-to-inform-the-optimizers-that-some-code-should-stay-unchanged-tp31039471p31066087.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Reasonably Related Threads
- [LLVMdev] metadata to inform the optimizers that some code should stay unchanged
- [LLVMdev] Values have no names when generating *.ll files in clang and llvm 2.8 ?
- [LLVMdev] How to .. jump from inline asm to a BasicBlock?
- [LLVMdev] Prevent instruction elimination
- [LLVMdev] Prevent instruction elimination