Improved -fclash-debug-* flags#1847
Conversation
| instance Hashable DebugOpts where | ||
| hashWithSalt s DebugOpts{..} = | ||
| s `hashWithSalt` | ||
| opt_invariants `hashWithSalt` | ||
| opt_transformationInfo `hashSet` | ||
| opt_transformations `hashWithSalt` | ||
| opt_countTransformations `hashWithSalt` | ||
| opt_transformationsFrom `hashWithSalt` | ||
| opt_transformationsLimit `hashWithSalt` | ||
| opt_historyFile | ||
| where | ||
| hashSet = Set.foldl' hashWithSalt | ||
| infixl 0 `hashSet` |
There was a problem hiding this comment.
Any reason to not just derive Hashable?
There was a problem hiding this comment.
I did wonder about that. Hashable isn't derived for ClashOpts, so when I defined this one I just moved the relevant lines from that instance + added the ones for the new fields to be safe
There was a problem hiding this comment.
Hmmm, my guess is that that's a leftover from a feature/hack we've since moved to the right place?:
clash-compiler/clash-lib/src/Clash/Driver/Manifest.hs
Lines 370 to 408 in aaf1559
I think we can just remove it and derive Hashable - in a separate commit of course so we can rollback if necessary.
There was a problem hiding this comment.
Ah, Set String has no Hashable instance, so deriving would fail
There was a problem hiding this comment.
And same for OverridingBool in ClashOpts. So I guess without making any more *.Extra modules we wouldn't be able to derive these instances
There was a problem hiding this comment.
Ah. Do we rely on the ordering? HashSet is generally preferable anyway. Which would leave OverridingBool - I guess an orphan instance wouldn't hurt.
There was a problem hiding this comment.
Do we rely on the ordering?
No, it's just a set of transformations which are whitelisted for showing in the debug logs. I had thought that there should probably be a later commit to change it from String to Text, maybe that should be a commit to change it from Set String to HashSet Text?
There was a problem hiding this comment.
I think I'm going to save this kind of type shake-up for a future PR, there are a few places where the types in rewrite / normalize could be improved and fiddling with types seems a bit tangential to this PR
3e89582 to
1237446
Compare
2892b80 to
e4520b3
Compare
|
@leonschoorl I've changed |
Things like the count of transformations applied and the offset / limits for transformations when debugging cannot be negative, so it makes more sense to use Word instead of Int for these.
7240791 to
5a93512
Compare
|
Wow, the term in IntegralTB with 8.10 is so big is doesn't even get to print the actually error. |
|
That's how you know it's |
|
Don't change when type-change-errors are reported compared to how it is now on HEAD of |
Yeah, seems reasonable. It'll be a little non-obvious to read with the new check (what does the amount of info printed about transformed terms have to do with type errors?) but the behaviour will be identical. I'll leave a comment for archaeology / to reference to #1064 so it's clearer to anyone who happens across it in the future |
The debugging options for the compiler are often used together, yet are passed individually to the rewrite system. Keeping debugging options together helps expose less unnecessary detail.
| -- not keep casts, so "illegally" changing between `Signal dom a` and `a` | ||
| -- will trigger this error for many designs. | ||
| -- | ||
| -- This should be changed when #1064 (PR to keep casts in core) is merged. |
There was a problem hiding this comment.
Apart from casts, wasn't this also triggered by separateArguments?
There was a problem hiding this comment.
The implicit params thing? Yeah, I didn't include that because by the time the signal cast PR is in it might not be an issue / there might be other small issues so I didn't want to get too into detail past the most immediate obstacle
The old
DebugLevelstyle debug options are replaced with a more granular style, where different options can be set independently. This allows things not previously possible, such as counting transformations without having to print any normalized core.The old
-fclash-debugflag still works in the same way for backwards compatibility. Additional command line flags are now available to directly set options from the new type:-fclash-debug-invariantschecks for invariants and displays warnings / errors. Setting this alone is equivalent toDebugSilent.-fclash-debug-infosets the amount of information to display when applying transformations. This overlaps a lot with the oldDebugLeveltype, but is named more consistently.-fclash-debug-count-transformationscounts the number of transformations applied (without showing any normalized core likeDebugCountdid)Additionally, the debugging options are now in their own type (
DebugOpts) which is accessed directly through theRewriteEnvinapply/applyDebuginstead of having the individual debugging options passed as inputs to the function. This simplifies the logic slightly in these functions and avoids needing to callapplyDebugrecursively with modified values.Fixes #1800
Still TODO: