I understand that _in general_ determining what a pointer points to at compile time is undecidable. I think what I want is a conservative points-to enhanced constant propagation (followed by dead code elimination to hopefully remove the address-of expression entirely). It sounds like I can pretty much use ptranal as is. I was hoping that I could also reuse a big chunk of something like partial.ml to get the transformation infrastructure.
On a big tangent, has anyone ever been tempted to recast Cil's analyses and optimizations in a composable framework, a la [1]? Ben [1] http://portal.acm.org/citation.cfm?id=503298 On Sep 9, 2009, at 7:38 AM, Stephen Magill wrote: > I haven't tried this, but I suspect a pointer analysis could help > you obtain a more general solution. Take a look at ptranal.ml in > the cil src/ext/pta directory. There will still be a lot of cases > where this won't work though (due, as Gabriel pointed out, to the > undecidability of the problem in general). > > --Stephen > > On Wed, Sep 9, 2009 at 2:42 AM, Gabriel Kerneis <kern...@pps.jussieu.fr > > wrote: > On Tue, Sep 08, 2009 at 10:33:46PM -0700, Benjamin Ylvisaker wrote: >> Does anyone know if there is any existing optimization in Cil that >> will do the translation of >> >> int a; >> int *b = &a; >> *b = 4; >> ... >> >> into >> >> int a; >> int *b = &a; >> a = 4; >> ... >> >> ? > > This is undecidable in the general case. But if you only need to match > this very specific pattern (X = &Y; *X = ... ; => X = &Y; Y = ...;), > it > is straightforward to write a visitor performing the optimisation. > Cil.peepHole2 is a generic function to do such things. > > Regards, > -- > Gabriel Kerneis ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users