Two Hoopl questions

Jan Stolarek jan.stolarek at p.lodz.pl
Wed Jul 31 13:07:14 CEST 2013


OK, I think I didn't give enough explanation in my last mail. My understanding is that entry block of the graph will be initialized with a fact (Const M.empty), while every other node will be initialized with Bottom. Now, when I reach a block that is first block in a loop it will have more than one predecessor (let's assume that it has two). One predecessor will have fact (Const ...) propagated from the entry node, but the other one will not be analyzed yet and therefore should be Bottom. That's why I think it should be picked up by first equation of joinCpFacts. Later on, when we reach end of a loop we will propagate (Const ...) to the entry block of a loop and only then we will be joining two (Const ...) facts - that's when second equation of joinCpFacts should come in to play.

Janek

----- Oryginalna wiadomość -----
Od: "Jan Stolarek" <jan.stolarek at p.lodz.pl>
Do: "Edward Z. Yang" <ezyang at MIT.EDU>
DW: "Simon Peyton-Jones" <simonpj at microsoft.com>, "ghc-devs" <ghc-devs at haskell.org>
Wysłane: środa, 31 lipiec 2013 10:00:51
Temat: Re: Two Hoopl questions

For some reason they are ignored, or at least the rewritten code looks as if only a single pass was done. I have facts represented like this:

  data AssignmentFactBot a = Bottom
                           | Const (M.Map a CmmExpr)

I initialize the entry node with:

     g' <- dataflowPassFwd graph [(entry_blk, Const M.empty)] $
           analRewFwd cpLattice cpTransfer (cpRewrite dflags)

And lattice is initialized with Bottom. Now the join function:

joinCpFacts        old   Bottom     = panic "AAAAAAAAAAA"
joinCpFacts (Const old) (Const new) = ...
joinCpFacts Bottom Bottom    = panic "Joining bottom with bottom"
joinCpFacts Bottom (Const _) = panic "Joining bottom with const"

Two last panics are intended - they should never happen. The first one is for debugging purposes and surprisingly it is never called - only the second equation is. I'm puzzled. Where did I go wrong?

Janek


----- Oryginalna wiadomość -----
Od: "Edward Z. Yang" <ezyang at MIT.EDU>
Do: "Jan Stolarek" <jan.stolarek at p.lodz.pl>
DW: "Simon Peyton-Jones" <simonpj at microsoft.com>, "ghc-devs" <ghc-devs at haskell.org>
Wysłane: wtorek, 30 lipiec 2013 20:40:53
Temat: Re: Two Hoopl questions

What happens when you put a loop in your code?

Edward

Excerpts from Jan Stolarek's message of Tue Jul 30 08:34:44 -0700 2013:
> I'll allow myself to ask my second question again:
> 
> 2) In my algorithm I need to initialize all of the blocks in a graph with bottom element of a lattice, except for the entry block, which needs some other initial values. I've written something like this:
> 
> cmmCopyPropagation dflags graph = do
>     let entry_blk = g_entry graph
>     g' <- dataflowPassFwd graph [(entry_blk, (Top, Top))] $
>             analRewFwd cpLattice cpTransfer cpRewrite
>     return . fst $ g'
> 
> cpLattice = DataflowLattice "copy propagation" (Bottom, Bottom) cpJoin
> 
> However, it seems that Bottom values passed to cpLattice are ignored - I could replace second parameter to DataflowLattice with `undefined` and the code would still run without causing an error. Is there something obviously wrong in the way I pass initial fact values to dataflowPassFwd, or should I look for the problem in other parts of my code?
> 
> Janek





More information about the ghc-devs mailing list