I was reading this page: http://llvm.org/docs/Passes.html and there seems to be lots of passes that depend on others to produce consistent non-redundant code. For instance, the DIE must run after Simple constant propagation, Loop-Closed SSA Form Pass is mostly (only) useful for other passes, such as LoopUnswitching, and a few passes that leave a good mess, requiring other passes to run afterwards to clean up. Is there any map of dependencies/recommendations for the passes? Does clang/opt cares if the user tries to use one without the other (warning)? cheers, --renato Reclaim your digital rights, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm
On Sun, Nov 15, 2009 at 1:20 PM, Renato Golin <rengolin at systemcall.org> wrote:> Is there any map of dependencies/recommendations for the passes? Does > clang/opt cares if the user tries to use one without the other > (warning)?Any arbitrary set of pass arguments should work; strong dependencies, are added automatically by the pass manager. You can see the passes which are getting implicitly added by passing "-debug-pass=Arguments" to opt; try running "opt -licm -debug-pass=Arguments < /dev/null -S" to get an idea of what happens here. Nothing will warn you if you do something silly like run -instcombine twice in a row, though. http://llvm.org/svn/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h has the set of passes llvm-gcc, clang, and opt run for -O1/2/3; there are some useful comments there in terms of choosing which passes to run. -Eli
2009/11/15 Eli Friedman <eli.friedman at gmail.com>:> Any arbitrary set of pass arguments should work; strong dependencies, > are added automatically by the pass manager.That answers my question, thanks! Maybe some warnings (if enabled) to make sure not only the strong dependencies are met, but all of them.> Nothing will warn you if you do something silly like run -instcombine > twice in a row, though.I'd suspect that running N times the same pass won't change the code a single bit more than running once. cheers, --renato Reclaim your digital rights, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm
On Sun, Nov 15, 2009 at 1:20 PM, Renato Golin <rengolin at systemcall.org> wrote:> I was reading this page: > http://llvm.org/docs/Passes.html > > and there seems to be lots of passes that depend on others to produce > consistent non-redundant code. > > For instance, the DIE must run after Simple constant propagation, > Loop-Closed SSA Form Pass is mostly (only) useful for other passes, > such as LoopUnswitching, and a few passes that leave a good mess, > requiring other passes to run afterwards to clean up.Usually, a pass has two kind of dependencies. 1) Info it needs to do its job. e.g. loop info, dominator tree, alias analysis etc... A pass can request these requirements explicitly and pass manager will sequence appropriate passes to meet the requirement. 2) IR form it needs to identify pattern and do its job. E.g. loop unswitch. loop rotation. etc.. In such cases, these passes should be added in pass queue by the driver (clang, or opt, or llvm-gcc) before your pass. However, your pass should be able to gracefully handle (and skip code) if the incoming IR is not in suitable form. - Devang
2009/11/16 Devang Patel <devang.patel at gmail.com>:> A pass can request these requirements explicitly and pass manager > will sequence appropriate passes to meet the requirement.So if two different passes request a third one independently, that third is going to run twice?> In such cases, these passes should be added in pass queue by the > driver (clang, or opt, or llvm-gcc) before your pass. However, your > pass should be able to gracefully handle (and skip code) if the > incoming IR is not in suitable form.This way, it's the caller responsibility to assure consistency, right? It could be possible that some required passes are not run if the caller doesn't do it properly. cheers, --renato Reclaim your digital rights, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm