File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,47 @@ cpp-options: -DBENCH_containers_Map -DBENCH_containers_IntMap -DBENCH_hashmap_Ma
6060* [ Documentation for our benchmark framework, ` tasty-bench ` ] ( https://github.com/Bodigrim/tasty-bench#readme )
6161
6262
63+ ## Inspecting the generated code
64+
65+ The library section in ` unordered-containers.cabal ` contains a commented-out set of ` ghc-options ` for
66+ dumping Core and other forms of generated code. To dump this code, uncomment these options and run
67+
68+ ```
69+ cabal clean
70+ cabal build
71+ ```
72+
73+ You can find the resulting ` .dump-* ` files in ` dist-newstyle/build/**/unordered-containers-*/build/ ` , e.g.
74+
75+ ```
76+ $ tree dist-newstyle/build/x86_64-linux/ghc-9.2.2/unordered-containers-0.2.16.0/build/
77+ dist-newstyle/build/x86_64-linux/ghc-9.2.2/unordered-containers-0.2.16.0/build/
78+ ├── Data
79+ │ ├── HashMap
80+ │ │ ├── Internal
81+ │ │ │ ├── Array.dump-asm
82+ │ │ │ ├── Array.dump-cmm
83+ │ │ │ ├── Array.dump-simpl
84+ │ │ │ ├── Array.dump-stg-final
85+ ...
86+ ```
87+
88+ To visually compare the generated code from two different states of the source tree, you can copy
89+ the ` dist-newstyle/build/**/unordered-containers-*/build/ ` directory from each state to two
90+ directories ` a ` and ` b ` and then use a diff tool like [ Meld] ( https://meldmerge.org/ ) to compare
91+ them:
92+
93+ ```
94+ meld a/ b/
95+ ```
96+
97+ ### References
98+
99+ * [ A collection of resources on GHC Core] ( https://stackoverflow.com/q/6121146/1013393 )
100+ * [ Some links about STG] ( https://stackoverflow.com/a/12118567/1013393 )
101+ * [ GHC User's Guide: _ Debugging the compiler_ ] ( http://downloads.haskell.org/~ghc/latest/docs/html/users_guide/debugging.html )
102+
103+
63104## Code style
64105
65106This package uses [ ` stylish-haskell ` ] ( https://hackage.haskell.org/package/stylish-haskell )
Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ library
6969
7070 ghc-options : -Wall -O2 -fwarn-tabs -ferror-spans
7171
72+ -- For dumping the generated code:
73+ -- ghc-options: -ddump-simpl -ddump-stg-final -ddump-cmm -ddump-asm -ddump-to-file
74+ -- ghc-options: -dsuppress-coercions -dsuppress-unfoldings -dsuppress-module-prefixes
75+ -- ghc-options: -dsuppress-uniques -dsuppress-timestamps
76+
7277 if flag(debug)
7378 cpp-options : -DASSERTS
7479
You can’t perform that action at this time.
0 commit comments