Skip to content

Commit 187c397

Browse files
authored
Move CSE to the unimplemented-in-the-certifier category (#7734)
* Move CSE to the unimplemented-in-the-certifier category * Remove dead code * Fix order of constructors in Agda <-> Haskell FFI
1 parent b3cd77f commit 187c397

21 files changed

Lines changed: 210 additions & 690 deletions

File tree

plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Transform/Certify/Trace.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@ certified.
1515
1616
This means that these passes are formalized as part of the certifier,
1717
and adding a new pass constructor to this type means that it is expected
18-
the pass will be also certified in the same PR. -}
18+
the pass will be also certified in the same PR.
19+
20+
IMPORTANT: the order of the constructors MUST be the same as the order
21+
of their counterparts in 'VerifiedCompilation.Trace'. -}
1922
data CertifiedOptStage
2023
= FloatDelay
2124
| ForceDelay
2225
| ForceCaseDelay
2326
| Inline
24-
| CSE
2527
| ApplyToCase
2628
deriving stock (Show, Generic)
2729
deriving anyclass (NFData)
2830

2931
{-| Datatype which represents optimization passes which are not yet
3032
certified.
3133
34+
IMPORTANT: the order of the constructors MUST be the same as the order
35+
of their counterparts in 'VerifiedCompilation.Trace'.
36+
3237
IMPORTANT: if you add a new pass, or modify an existing pass, without
3338
also modifying the certifier in the same PR, you must add/move its
3439
corresponding constructor to this type. Please also open an issue
@@ -37,6 +42,7 @@ data UncertifiedOptStage
3742
= CaseOfCase
3843
| LetFloatOut
3944
| CaseReduce
45+
| CSE
4046
deriving stock (Show, Generic)
4147
deriving anyclass (NFData)
4248

@@ -58,7 +64,7 @@ pattern InlineStage :: OptStage
5864
pattern InlineStage = Right Inline
5965

6066
pattern CseStage :: OptStage
61-
pattern CseStage = Right CSE
67+
pattern CseStage = Left CSE
6268

6369
pattern ApplyToCaseStage :: OptStage
6470
pattern ApplyToCaseStage = Right ApplyToCase
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Removed
2+
3+
- Temporarily disabled the CSE certifier pass due to the discovery of bugs in the specification.

plutus-metatheory/plutus-metatheory.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,6 @@ library
377377
MAlonzo.Code.VerifiedCompilation.Trace
378378
MAlonzo.Code.VerifiedCompilation.UApplyToCase
379379
MAlonzo.Code.VerifiedCompilation.UCaseOfCase
380-
MAlonzo.Code.VerifiedCompilation.UCaseReduce
381-
MAlonzo.Code.VerifiedCompilation.UCSE
382380
MAlonzo.Code.VerifiedCompilation.UFloatDelay
383381
MAlonzo.Code.VerifiedCompilation.UForceCaseDelay
384382
MAlonzo.Code.VerifiedCompilation.UForceDelay

plutus-metatheory/src/CertifierReport.lagda.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ showCertifiedOptTag floatDelayT = "Float Delay"
4040
showCertifiedOptTag forceDelayT = "Force-Delay Cancellation"
4141
showCertifiedOptTag forceCaseDelayT = "Float Force into Case Branches"
4242
showCertifiedOptTag inlineT = "Inlining"
43-
showCertifiedOptTag cseT = "Common Subexpression Elimination"
4443
showCertifiedOptTag applyToCaseT = "Transform multi-argument applications into case-constr form"
4544
4645
showUncertifiedOptTag : UncertifiedOptTag → String
4746
showUncertifiedOptTag caseOfCaseT = "Case-of-Case"
4847
showUncertifiedOptTag letFloatOutT = "Float bindings outwards"
4948
showUncertifiedOptTag caseReduceT = "Case-Constr and Case-Constant Cancellation"
49+
showUncertifiedOptTag cseT = "Common Subexpression Elimination"
5050
5151
showTag : OptTag → String
5252
showTag (inj₁ tag) = showUncertifiedOptTag tag ++ " ⚠ (certifier unavailable)"
@@ -116,7 +116,6 @@ numSitesInlineᵖʷ (x Pointwise.∷ xs) = numSitesInline x + numSitesInlineᵖ
116116
numSites : {M N : 0 ⊢} (tag : CertifiedOptTag) → RelationOf (inj₂ tag) M N → ℕ
117117
numSites forceDelayT p = numSites′ p
118118
numSites floatDelayT p = numSites′ p
119-
numSites cseT p = numSites′ p
120119
numSites inlineT p = numSitesInline p
121120
numSites forceCaseDelayT p = numSites′ p
122121
numSites applyToCaseT p = numSites′ p

plutus-metatheory/src/FFI/AgdaUnparse.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ instance AgdaUnparse CertifiedOptStage where
5555
agdaUnparse ForceDelay = "forceDelayT"
5656
agdaUnparse ForceCaseDelay = "forceCaseDelayT"
5757
agdaUnparse Inline = "inlineT"
58-
agdaUnparse CSE = "cseT"
5958
agdaUnparse ApplyToCase = "applyToCaseT"
6059

6160
instance AgdaUnparse UncertifiedOptStage where
6261
agdaUnparse CaseOfCase = "caseOfCaseT"
6362
agdaUnparse LetFloatOut = "letFloatOutT"
6463
agdaUnparse CaseReduce = "caseReduceT"
64+
agdaUnparse CSE = "cseT"
6565

6666
instance AgdaUnparse Hints.Hints where
6767
agdaUnparse = \case

plutus-metatheory/src/MAlonzo/Code/Certifier.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ d_runCertifier_2 ::
3333
[MAlonzo.Code.Utils.T__'215'__428
3434
(MAlonzo.Code.Utils.T_Either_6
3535
MAlonzo.Code.VerifiedCompilation.Trace.T_UncertifiedOptTag_4
36-
MAlonzo.Code.VerifiedCompilation.Trace.T_CertifiedOptTag_12)
36+
MAlonzo.Code.VerifiedCompilation.Trace.T_CertifiedOptTag_14)
3737
(MAlonzo.Code.Utils.T__'215'__428
3838
MAlonzo.Code.VerifiedCompilation.Trace.T_Hints_72
3939
(MAlonzo.Code.Utils.T__'215'__428
@@ -77,7 +77,7 @@ runCertifierMain ::
7777
(MAlonzo.Code.Utils.T__'215'__428
7878
(MAlonzo.Code.Utils.T_Either_6
7979
MAlonzo.Code.VerifiedCompilation.Trace.T_UncertifiedOptTag_4
80-
MAlonzo.Code.VerifiedCompilation.Trace.T_CertifiedOptTag_12)
80+
MAlonzo.Code.VerifiedCompilation.Trace.T_CertifiedOptTag_14)
8181
(MAlonzo.Code.Utils.T__'215'__428
8282
MAlonzo.Code.VerifiedCompilation.Trace.T_Hints_72
8383
(MAlonzo.Code.Utils.T__'215'__428
@@ -94,7 +94,7 @@ d_runCertifierMain_12 ::
9494
[MAlonzo.Code.Utils.T__'215'__428
9595
(MAlonzo.Code.Utils.T_Either_6
9696
MAlonzo.Code.VerifiedCompilation.Trace.T_UncertifiedOptTag_4
97-
MAlonzo.Code.VerifiedCompilation.Trace.T_CertifiedOptTag_12)
97+
MAlonzo.Code.VerifiedCompilation.Trace.T_CertifiedOptTag_14)
9898
(MAlonzo.Code.Utils.T__'215'__428
9999
MAlonzo.Code.VerifiedCompilation.Trace.T_Hints_72
100100
(MAlonzo.Code.Utils.T__'215'__428
@@ -121,15 +121,15 @@ d_runCertifierMain_12 v0 v1
121121
MAlonzo.Code.Utils.C__'44'__442
122122
(coe MAlonzo.Code.Agda.Builtin.Bool.C_false_8)
123123
(coe
124-
MAlonzo.Code.CertifierReport.d_makeReport_284 (coe v2) (coe v1)))
124+
MAlonzo.Code.CertifierReport.d_makeReport_282 (coe v2) (coe v1)))
125125
MAlonzo.Code.VerifiedCompilation.C_abort_10 v4
126126
-> coe
127127
MAlonzo.Code.Agda.Builtin.Maybe.C_just_16
128128
(coe
129129
MAlonzo.Code.Utils.C__'44'__442
130130
(coe MAlonzo.Code.Agda.Builtin.Bool.C_false_8)
131131
(coe
132-
MAlonzo.Code.CertifierReport.d_makeReport_284 (coe v2) (coe v1)))
132+
MAlonzo.Code.CertifierReport.d_makeReport_282 (coe v2) (coe v1)))
133133
_ -> MAlonzo.RTE.mazUnreachableError
134134
MAlonzo.Code.Utils.C_inj'8322'_14 v3
135135
-> coe
@@ -140,5 +140,5 @@ d_runCertifierMain_12 v0 v1
140140
MAlonzo.Code.Utils.C__'44'__442
141141
(coe MAlonzo.Code.Agda.Builtin.Bool.C_true_10)
142142
(coe
143-
MAlonzo.Code.CertifierReport.d_makeReport_284 (coe v2) (coe v1))))
143+
MAlonzo.Code.CertifierReport.d_makeReport_282 (coe v2) (coe v1))))
144144
_ -> MAlonzo.RTE.mazUnreachableError)

0 commit comments

Comments
 (0)