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
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
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
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.
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
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?
If the two users do not destroy the info collected by the third pass.
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.
Yes. You can write your own 'opt' tool (it is very simple) and
sequence the transformation passes the way you want. And it should
work.