Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,827
    • Issues 4,827
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 440
    • Merge requests 440
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Wiki
  • Commentary
  • Compiler
  • Hoopl
  • examples

examples · Changes

Page history
Edit Commentary/Compiler/Hoopl/Examples authored Feb 01, 2014 by jstolarek's avatar jstolarek
Hide whitespace changes
Inline Side-by-side
commentary/compiler/hoopl/examples.md 0 → 100644
View page @ 6fc1b833
# Hoopl examples
This page gathers examples of Hoopl usage so that beginners can learn from them.
## Dead assignment removal
This was originally part of `CmmLive` module:
```wiki
removeDeadAssignments :: DynFlags -> CmmGraph
-> UniqSM (CmmGraph, BlockEnv CmmLocalLive)
removeDeadAssignments dflags g =
dataflowPassBwd g [] $ analRewBwd liveLattice (xferLive dflags) rewrites
where rewrites = mkBRewrite3 nothing middle nothing
-- SDM: no need for deepBwdRw here, we only rewrite to empty
-- Beware: deepBwdRw with one polymorphic function seems more
-- reasonable here, but GHC panics while compiling, see bug
-- #4045.
middle :: CmmNode O O -> Fact O CmmLocalLive -> CmmReplGraph O O
middle (CmmAssign (CmmLocal reg') _) live
| not (reg' `elemRegSet` live)
= return $ Just emptyGraph
-- XXX maybe this should be somewhere else...
middle (CmmAssign lhs (CmmReg rhs)) _ | lhs == rhs
= return $ Just emptyGraph
middle (CmmStore lhs (CmmLoad rhs _)) _ | lhs == rhs
= return $ Just emptyGraph
middle _ _ = return Nothing
nothing :: CmmNode e x -> Fact x CmmLocalLive -> CmmReplGraph e x
nothing _ _ = return Nothing
```
## CmmRewriteAssignments optimization pass
The `CmmRewriteAssignments` pass was originally written by Edward Z. Yang to perform Cmm optimizations like inlining and sinking. However, it turned out to be too slow and was replaced with `CmmSink` pass written by Simon Marlow. `CmmSink` does almost the same things as `CmmRewriteAssignments`, the most notable difference being that the former does not handle loops. Code of `CmmRewriteAssignments` is available in [this attachment](/trac/ghc/attachment/wiki/Commentary/Compiler/Hoopl/Examples/CmmRewriteAssignments.hs)[](/trac/ghc/raw-attachment/wiki/Commentary/Compiler/Hoopl/Examples/CmmRewriteAssignments.hs).
Clone repository Edit sidebar
  • Adventures in GHC compile times
  • All things layout
  • AndreasK
  • AndreasPK
  • Back End and Run Time System
  • Backpack refactoring
  • Backpack units
  • Brief Guide for Compiling GHC to iOS
  • Building GHC on Windows with Stack protector support (SSP) (using Make)
  • CAFs
  • CafInfo rework
  • Compiling Case Expressions in ghc
  • Compiling Data.Aeson Error
  • Contributing a Patch
  • Core interface section
View All Pages