On Nov 29, 2010, at 1:17 AM, Duncan Sands wrote:> Hi David, > >> Interesting -- LLVM does perform on the fly cleanups during inlining >> transformation -- this will make summary update precise. One thing I notice from >> the debug pass dump is that the 'deduce function attribute' pass happens before >> the clean up -- Is it intended? > > you are correct. This is due to a limitation of the pass manager: it would > clearly be better to run the function attributes pass after the per-function > passes that follow the inliner, but currently if you try what happens is that > first the inliner and on the fly cleanups get run on every function, and only > when they have finished the function attributes pass gets run on every > function. That means that function attributes of callees will not have been > calculated when the inliner (and the subsequent function passes) process a > function, which is bad. I think the pass manager should be fixed to not do > this, at which point the function attributes pass could be moved later.I am not sure I understand this. Here is what I am seeing when I run 'opt -inline -instcombine -functionattrs' Target Data Layout No Alias Analysis (always returns 'may' alias) ModulePass Manager Basic CallGraph Construction Call Graph SCC Pass Manager Function Integration/Inlining FunctionPass Manager Combine redundant instructions Basic CallGraph Construction Call Graph SCC Pass Manager Deduce function attributes FunctionPass Manager Preliminary module verification Dominator Tree Construction Module Verifier Is this not what you expect ? - Devang
On Nov 29, 2010, at 5:01 PM, Devang Patel wrote:> > On Nov 29, 2010, at 1:17 AM, Duncan Sands wrote: > >> Hi David, >> >>> Interesting -- LLVM does perform on the fly cleanups during inlining >>> transformation -- this will make summary update precise. One thing I notice from >>> the debug pass dump is that the 'deduce function attribute' pass happens before >>> the clean up -- Is it intended? >> >> you are correct. This is due to a limitation of the pass manager: it would >> clearly be better to run the function attributes pass after the per-function >> passes that follow the inliner, but currently if you try what happens is that >> first the inliner and on the fly cleanups get run on every function, and only >> when they have finished the function attributes pass gets run on every >> function. That means that function attributes of callees will not have been >> calculated when the inliner (and the subsequent function passes) process a >> function, which is bad. I think the pass manager should be fixed to not do >> this, at which point the function attributes pass could be moved later. > > I am not sure I understand this. Here is what I am seeing when I run > 'opt -inline -instcombine -functionattrs' > > Target Data Layout > No Alias Analysis (always returns 'may' alias) > ModulePass Manager > Basic CallGraph Construction > Call Graph SCC Pass Manager > Function Integration/Inlining > FunctionPass Manager > Combine redundant instructions > Basic CallGraph Construction > Call Graph SCC Pass Manager > Deduce function attributes > FunctionPass Manager > Preliminary module verification > Dominator Tree Construction > Module Verifier > > > Is this not what you expect ? >And if you run 'opt -inline -functionattrs -instcombine' you get Target Data Layout No Alias Analysis (always returns 'may' alias) ModulePass Manager Basic CallGraph Construction Call Graph SCC Pass Manager Function Integration/Inlining Deduce function attributes FunctionPass Manager Combine redundant instructions Preliminary module verification Dominator Tree Construction Module Verifier - Devang
On Nov 29, 2010, at 5:01 PM, Devang Patel wrote:> > On Nov 29, 2010, at 1:17 AM, Duncan Sands wrote: > >> Hi David, >> >>> Interesting -- LLVM does perform on the fly cleanups during inlining >>> transformation -- this will make summary update precise. One thing I notice from >>> the debug pass dump is that the 'deduce function attribute' pass happens before >>> the clean up -- Is it intended? >> >> you are correct. This is due to a limitation of the pass manager: it would >> clearly be better to run the function attributes pass after the per-function >> passes that follow the inliner, but currently if you try what happens is that >> first the inliner and on the fly cleanups get run on every function, and only >> when they have finished the function attributes pass gets run on every >> function. That means that function attributes of callees will not have been >> calculated when the inliner (and the subsequent function passes) process a >> function, which is bad. I think the pass manager should be fixed to not do >> this, at which point the function attributes pass could be moved later. > > I am not sure I understand this. Here is what I am seeing when I run > 'opt -inline -instcombine -functionattrs' > > Target Data Layout > No Alias Analysis (always returns 'may' alias) > ModulePass Manager > Basic CallGraph Construction > Call Graph SCC Pass Manager > Function Integration/Inlining > FunctionPass Manager > Combine redundant instructions > Basic CallGraph Construction > Call Graph SCC Pass Manager > Deduce function attributes > FunctionPass Manager > Preliminary module verification > Dominator Tree Construction > Module Verifier > > > Is this not what you expect ?I'd expect (ignoring the verifier): Target Data Layout No Alias Analysis (always returns 'may' alias) ModulePass Manager Basic CallGraph Construction Call Graph SCC Pass Manager Function Integration/Inlining FunctionPass Manager Combine redundant instructions Deduce function attributes -Chris
On Nov 29, 2010, at 5:15 PM, Chris Lattner wrote:> > On Nov 29, 2010, at 5:01 PM, Devang Patel wrote: > >> >> On Nov 29, 2010, at 1:17 AM, Duncan Sands wrote: >> >>> Hi David, >>> >>>> Interesting -- LLVM does perform on the fly cleanups during inlining >>>> transformation -- this will make summary update precise. One thing I notice from >>>> the debug pass dump is that the 'deduce function attribute' pass happens before >>>> the clean up -- Is it intended? >>> >>> you are correct. This is due to a limitation of the pass manager: it would >>> clearly be better to run the function attributes pass after the per-function >>> passes that follow the inliner, but currently if you try what happens is that >>> first the inliner and on the fly cleanups get run on every function, and only >>> when they have finished the function attributes pass gets run on every >>> function. That means that function attributes of callees will not have been >>> calculated when the inliner (and the subsequent function passes) process a >>> function, which is bad. I think the pass manager should be fixed to not do >>> this, at which point the function attributes pass could be moved later. >> >> I am not sure I understand this. Here is what I am seeing when I run >> 'opt -inline -instcombine -functionattrs' >> >> Target Data Layout >> No Alias Analysis (always returns 'may' alias) >> ModulePass Manager >> Basic CallGraph Construction >> Call Graph SCC Pass Manager >> Function Integration/Inlining >> FunctionPass Manager >> Combine redundant instructions >> Basic CallGraph Construction >> Call Graph SCC Pass Manager >> Deduce function attributes >> FunctionPass Manager >> Preliminary module verification >> Dominator Tree Construction >> Module Verifier >> >> >> Is this not what you expect ? > > I'd expect (ignoring the verifier): > > Target Data Layout > No Alias Analysis (always returns 'may' alias) > ModulePass Manager > Basic CallGraph Construction > Call Graph SCC Pass Manager > Function Integration/Inlining > FunctionPass Manager > Combine redundant instructions > Deduce function attributes >Right now PassManager is not doing this because instcombine does not state that it preserves Inlining and Basic CallGraph Construction. - Devang