File tree 2 files changed +46
-0
lines changed
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
60
60
* [ Documentation for our benchmark framework, ` tasty-bench ` ] ( https://github.com/Bodigrim/tasty-bench#readme )
61
61
62
62
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
+
63
104
## Code style
64
105
65
106
This 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
69
69
70
70
ghc-options : -Wall -O2 -fwarn-tabs -ferror-spans
71
71
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
+
72
77
if flag(debug)
73
78
cpp-options : -DASSERTS
74
79
You can’t perform that action at this time.
0 commit comments