diff --git a/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs b/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs index 7ba8793f0e5..6fe0f8bcab5 100644 --- a/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs +++ b/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs @@ -620,6 +620,7 @@ hoistExpr hoistExpr var t = do wrapUnsafeDataAsConstrName <- lookupGhcName 'PlutusTx.AsData.Internal.wrapUnsafeDataAsConstr + anchorName <- lookupGhcName 'PlutusTx.Plugin.Utils.anchor let name = GHC.getName var lexName = LexName name @@ -638,10 +639,15 @@ hoistExpr var t = do -- See Note [Dependency tracking] modifyCurDeps (Set.insert lexName) maybeDef <- PIR.lookupTerm lexName - let varSpan = getVarSourceSpan var + -- Source spans only come from @anchor@ wrappers injected by Plinth.Plugin. + -- @GHC.nameSrcSpan@ on imported Vars is unreliable because it depends on the + -- defining module being recompiled from source (issue #7203/#7722), so it is + -- deliberately not consulted — we prefer a missing span over a flaky one. + let varSpan = findAnchorLoc anchorName t addSpan = case varSpan of Nothing -> id Just src -> fmap . fmap . addSrcSpan $ src ^. srcSpanIso + nameStr = GHC.occNameString $ GHC.occName $ GHC.varName var case maybeDef of Just term -> pure term -- See Note [Dependency tracking] @@ -653,27 +659,27 @@ hoistExpr var t = do (PIR.Def var' (PIR.mkVar var', PIR.Strict)) mempty - t' <- maybeProfileRhs var var' =<< addSpan (compileExpr Nothing t) + t' <- maybeProfileRhs varSpan nameStr var' =<< addSpan (compileExpr Nothing t) -- See Note [Non-strict let-bindings] PIR.modifyTermDef lexName (const $ PIR.Def var' (t', PIR.NonStrict)) pure $ PIR.mkVar var' --- 'GHC.Var' in argument is only for extracting srcspan and accurate name. +{-| Wrap the RHS of a definition with entry/exit profile traces when profiling +is enabled and the definition is a function/abstraction. The span is +resolved by the caller (see 'hoistExpr'), preferring an @anchor@-carried +span so it still works with GHC's interface cache. -} maybeProfileRhs :: CompilingDefault uni fun m ann - => GHC.Var + => Maybe GHC.RealSrcSpan + -> String -> PLCVar uni -> PIRTerm uni fun -> m (PIRTerm uni fun) -maybeProfileRhs ghcVar var t = do +maybeProfileRhs mSpan nameStr var t = do CompileContext {ccOpts = compileOpts} <- ask let - nameStr = GHC.occNameString $ GHC.occName $ GHC.varName $ ghcVar displayName = T.pack $ - case getVarSourceSpan ghcVar of - -- When module is not compiled and GHC is using cached build from previous build, it will - -- lack source span. There's nothing much we can do about this here since this is GHC - -- behavior. Issue #7203 + case mSpan of Nothing -> nameStr Just src -> nameStr <> " (" <> show (src ^. srcSpanIso) <> ")" @@ -1331,7 +1337,9 @@ compileExpr mloc e = do _ -> compileTypeNorm $ GHC.varType b -- See Note [Non-strict let-bindings] withVarTyScoped b ty $ \v -> do - rhs'' <- maybeProfileRhs b v rhs' + let bSpan = findAnchorLoc anchorName rhs + bName = GHC.occNameString (GHC.occName (GHC.varName b)) + rhs'' <- maybeProfileRhs bSpan bName v rhs' let binds = pure $ PIR.TermBind annMayInline PIR.NonStrict v rhs'' body' <- compileExpr Nothing body pure $ PIR.Let annMayInline PIR.NonRec binds body' @@ -1340,7 +1348,9 @@ compileExpr mloc e = do -- the bindings are scope in both the body and the args -- TODO: this is a bit inelegant matching the vars back up binds <- for (zip vars bs) $ \(v, (ghcVar, rhs)) -> do - rhs' <- maybeProfileRhs ghcVar v =<< compileExpr Nothing rhs + let gvSpan = findAnchorLoc anchorName rhs + gvName = GHC.occNameString (GHC.occName (GHC.varName ghcVar)) + rhs' <- maybeProfileRhs gvSpan gvName v =<< compileExpr Nothing rhs -- See Note [Non-strict let-bindings] pure $ PIR.TermBind annMayInline PIR.NonStrict v rhs' body' <- compileExpr Nothing body @@ -1535,9 +1545,6 @@ getSourceSpan mmb GHC.HpcTick {GHC.tickId = tid} = do return sp getSourceSpan _ _ = Nothing -getVarSourceSpan :: GHC.Var -> Maybe GHC.RealSrcSpan -getVarSourceSpan = GHC.srcSpanToRealSrcSpan . GHC.nameSrcSpan . GHC.varName - srcSpanIso :: Iso' GHC.RealSrcSpan SrcSpan srcSpanIso = iso fromGHC toGHC where @@ -1729,6 +1736,32 @@ extractLoc anchorName modBreaks = go Nothing go (Just ss) e other -> (acc, other) +{-| Find the first @anchor@-carried 'RealSrcSpan' anywhere inside a 'CoreExpr', +descending through applications, lambdas, lets, cases, casts, and ticks. +Useful when the immediate head of the expression is not an anchor call +(e.g. a hoisted top-level RHS that starts with a lambda). -} +findAnchorLoc :: GHC.Name -> GHC.CoreExpr -> Maybe GHC.RealSrcSpan +findAnchorLoc anchorName = go + where + firstJust = foldr ((<|>) . go) Nothing + go = \case + GHC.App + ( GHC.App + (GHC.App (GHC.Var f) (GHC.Type (GHC.LitTy (GHC.StrTyLit loc)))) + (GHC.Type _eTy) + ) + _ + | GHC.getName f == anchorName -> decodeSrcSpan (GHC.unpackFS loc) + GHC.App f x -> go f <|> go x + GHC.Lam _ b -> go b + GHC.Let (GHC.NonRec _ rhs) e -> go rhs <|> go e + GHC.Let (GHC.Rec bs) e -> firstJust (map snd bs) <|> go e + GHC.Case scrut _ _ alts -> + go scrut <|> firstJust [rhs | GHC.Alt _ _ rhs <- alts] + GHC.Cast e _ -> go e + GHC.Tick _ e -> go e + _ -> Nothing + extractUnsupported :: GHC.Name -> GHC.CoreExpr diff --git a/plutus-tx-plugin/src/PlutusTx/Plugin/Common.hs b/plutus-tx-plugin/src/PlutusTx/Plugin/Common.hs index 5184c0aee04..e02c33c776f 100644 --- a/plutus-tx-plugin/src/PlutusTx/Plugin/Common.hs +++ b/plutus-tx-plugin/src/PlutusTx/Plugin/Common.hs @@ -176,7 +176,10 @@ injectAnchors env = do let binds = GHC.tcg_binds env bindsAnchored = Compat.modifyBinds - (transformBi (stripGuardAnchors anchorId) . transformBi (anchorExpr anchorId)) + ( transformBi (stripGuardAnchors anchorId) + . transformBi (anchorBinding anchorId) + . transformBi (anchorExpr anchorId) + ) binds pure env {GHC.tcg_binds = bindsAnchored} @@ -185,13 +188,64 @@ anchorExpr :: GHC.Id -> GHC.LHsExpr GHC.GhcTc -> GHC.LHsExpr GHC.GhcTc anchorExpr anchorId le@(GHC.L ann e) | isAnchorWorthy anchorId e , Just !sp <- GHC.srcSpanToRealSrcSpan (GHC.locA ann) = + wrapWithAnchor anchorId sp le + | otherwise = le + +{-| Wrap an 'LHsExpr' with an @anchor@ carrying the given source span. Skips +expressions whose type might be unlifted (since @anchor@'s type variable has +kind @Type@). -} +wrapWithAnchor + :: GHC.Id + -> GHC.RealSrcSpan + -> GHC.LHsExpr GHC.GhcTc + -> GHC.LHsExpr GHC.GhcTc +wrapWithAnchor anchorId sp le@(GHC.L _ e) + | GHC.mightBeUnliftedType (GHC.hsExprType e) = le + | otherwise = let locStr = encodeSrcSpan sp locTy = GHC.LitTy (GHC.StrTyLit (GHC.mkFastString locStr)) exprTy = GHC.hsExprType e wrapper = GHC.WpTyApp exprTy `GHC.WpCompose` GHC.WpTyApp locTy anchor = GHC.mkHsWrap wrapper (GHC.HsVar GHC.noExtField $ GHC.noLocA anchorId) in GHC.noLocA (Compat.hsAppTc (GHC.noLocA anchor) le) - | otherwise = le + +{-| Wrap the body of every 'GRHS' of a value binding with an @anchor@ carrying +the binder's source span. This gives 'findAnchorLoc' a reliable outer-most +anchor for every hoisted binding, so profile-trace output identifies which +function was entered (the span points to the binder, not an arbitrary +sub-expression). See issue #7722. -} +anchorBinding + :: GHC.Id + -> GHC.HsBindLR GHC.GhcTc GHC.GhcTc + -> GHC.HsBindLR GHC.GhcTc GHC.GhcTc +anchorBinding anchorId = \case + fb@GHC.FunBind {GHC.fun_id = GHC.L ann _, GHC.fun_matches = mg} + | Just sp <- GHC.srcSpanToRealSrcSpan (GHC.locA ann) -> + fb {GHC.fun_matches = wrapMatchGroup sp mg} + pb@GHC.PatBind {GHC.pat_lhs = GHC.L ann _, GHC.pat_rhs = grhss} + | Just sp <- GHC.srcSpanToRealSrcSpan (GHC.locA ann) -> + pb {GHC.pat_rhs = wrapGRHSs sp grhss} + other -> other + where + -- Extension constructors (XMG/XMatch/XGRHSs/XGRHS) are uninhabited for + -- 'GhcTc', but GHC's pattern coverage checker does not know that, so each + -- helper has a fall-through to silence the warning. + wrapMatchGroup sp = \case + mg@GHC.MG {GHC.mg_alts = lalts} -> + mg {GHC.mg_alts = (fmap . fmap . fmap) (wrapMatch sp) lalts} + other -> other + wrapMatch sp = \case + m@GHC.Match {GHC.m_grhss = grhss} -> + m {GHC.m_grhss = wrapGRHSs sp grhss} + other -> other + wrapGRHSs sp = \case + grhss@GHC.GRHSs {GHC.grhssGRHSs = lgrhss} -> + grhss {GHC.grhssGRHSs = (fmap . fmap) (wrapGRHS sp) lgrhss} + other -> other + wrapGRHS sp = \case + GHC.GRHS x guards body -> + GHC.GRHS x guards (wrapWithAnchor anchorId sp body) + other -> other isAnchorWorthy :: GHC.Id -> GHC.HsExpr GHC.GhcTc -> Bool isAnchorWorthy marker expr diff --git a/plutus-tx-plugin/test/CallTrace/9.6/func03.golden.eval b/plutus-tx-plugin/test/CallTrace/9.6/func03.golden.eval index 457943a4273..684e75a2f61 100644 --- a/plutus-tx-plugin/test/CallTrace/9.6/func03.golden.eval +++ b/plutus-tx-plugin/test/CallTrace/9.6/func03.golden.eval @@ -5,4 +5,4 @@ Caused by: error Trace: -> func (test/CallTrace/Spec.hs:84:1-84:4) -> functionFromOtherModule (test/CallTrace/Spec.hs:101:1-101:23) --> errorWhenTrue (test/CallTrace/OtherModule.hs:10:1-10:13) \ No newline at end of file +-> errorWhenTrue (test/CallTrace/OtherModule.hs:15:1-15:13) \ No newline at end of file diff --git a/plutus-tx-plugin/test/CallTrace/9.6/func05.golden.eval b/plutus-tx-plugin/test/CallTrace/9.6/func05.golden.eval index 369ceb39897..0eb9d5903ce 100644 --- a/plutus-tx-plugin/test/CallTrace/9.6/func05.golden.eval +++ b/plutus-tx-plugin/test/CallTrace/9.6/func05.golden.eval @@ -6,4 +6,4 @@ Trace: -> func (test/CallTrace/Spec.hs:84:1-84:4) -> $cmyClassFunc (test/CallTrace/Spec.hs:107:3-107:13) -> functionFromOtherModule (test/CallTrace/Spec.hs:101:1-101:23) --> errorWhenTrue (test/CallTrace/OtherModule.hs:10:1-10:13) \ No newline at end of file +-> errorWhenTrue (test/CallTrace/OtherModule.hs:15:1-15:13) \ No newline at end of file diff --git a/plutus-tx-plugin/test/CallTrace/9.6/func07.golden.eval b/plutus-tx-plugin/test/CallTrace/9.6/func07.golden.eval index 018b5f723f6..df15d7f919f 100644 --- a/plutus-tx-plugin/test/CallTrace/9.6/func07.golden.eval +++ b/plutus-tx-plugin/test/CallTrace/9.6/func07.golden.eval @@ -4,4 +4,4 @@ Caused by: error Trace: -> func (test/CallTrace/Spec.hs:84:1-84:4) --> $fMyClassInOtherModuleInteger_$cmyClassFuncInOtherModule (test/CallTrace/OtherModule.hs:24:3-24:26) \ No newline at end of file +-> $fMyClassInOtherModuleInteger_$cmyClassFuncInOtherModule (test/CallTrace/OtherModule.hs:25:3-25:26) \ No newline at end of file diff --git a/plutus-tx-plugin/test/CallTrace/9.6/func08.golden.eval b/plutus-tx-plugin/test/CallTrace/9.6/func08.golden.eval index a0f4aa9d7ef..4c8d7dd447e 100644 --- a/plutus-tx-plugin/test/CallTrace/9.6/func08.golden.eval +++ b/plutus-tx-plugin/test/CallTrace/9.6/func08.golden.eval @@ -4,5 +4,5 @@ Caused by: error Trace: -> func (test/CallTrace/Spec.hs:84:1-84:4) --> $fMyClassInOtherModuleInteger_$cmyClassFuncInOtherModule (test/CallTrace/OtherModule.hs:24:3-24:26) --> errorWhenTrue (test/CallTrace/OtherModule.hs:10:1-10:13) \ No newline at end of file +-> $fMyClassInOtherModuleInteger_$cmyClassFuncInOtherModule (test/CallTrace/OtherModule.hs:25:3-25:26) +-> errorWhenTrue (test/CallTrace/OtherModule.hs:15:1-15:13) \ No newline at end of file diff --git a/plutus-tx-plugin/test/CallTrace/9.6/func09.golden.eval b/plutus-tx-plugin/test/CallTrace/9.6/func09.golden.eval index 0c15ade4e49..1f02635771e 100644 --- a/plutus-tx-plugin/test/CallTrace/9.6/func09.golden.eval +++ b/plutus-tx-plugin/test/CallTrace/9.6/func09.golden.eval @@ -4,4 +4,4 @@ Caused by: error Trace: -> func (test/CallTrace/Spec.hs:84:1-84:4) --> $fMyClassInOtherModule()_$cmyClassFuncInOtherModule (test/CallTrace/OtherModule.hs:29:3-29:26) \ No newline at end of file +-> $fMyClassInOtherModule()_$cmyClassFuncInOtherModule (test/CallTrace/OtherModule.hs:30:3-30:26) \ No newline at end of file diff --git a/plutus-tx-plugin/test/CallTrace/9.6/funcionFromOtherModule-error.golden.eval b/plutus-tx-plugin/test/CallTrace/9.6/funcionFromOtherModule-error.golden.eval index 7e52df2404c..1cbc5a078cf 100644 --- a/plutus-tx-plugin/test/CallTrace/9.6/funcionFromOtherModule-error.golden.eval +++ b/plutus-tx-plugin/test/CallTrace/9.6/funcionFromOtherModule-error.golden.eval @@ -4,4 +4,4 @@ Caused by: error Trace: -> functionFromOtherModule (test/CallTrace/Spec.hs:101:1-101:23) --> errorWhenTrue (test/CallTrace/OtherModule.hs:10:1-10:13) \ No newline at end of file +-> errorWhenTrue (test/CallTrace/OtherModule.hs:15:1-15:13) \ No newline at end of file diff --git a/plutus-tx-plugin/test/CallTrace/9.6/successfullEvaluationYieldsNoTraceLog.golden.eval b/plutus-tx-plugin/test/CallTrace/9.6/successfullEvaluationYieldsNoTraceLog.golden.eval index 595ef84055e..10c56579377 100644 --- a/plutus-tx-plugin/test/CallTrace/9.6/successfullEvaluationYieldsNoTraceLog.golden.eval +++ b/plutus-tx-plugin/test/CallTrace/9.6/successfullEvaluationYieldsNoTraceLog.golden.eval @@ -1,7 +1,7 @@ -CPU: 1_653_088 -Memory: 8_392 -AST Size: 90 -Flat Size: 451 +CPU: 2_579_080 +Memory: 12_820 +AST Size: 116 +Flat Size: 489 No Trace Produced diff --git a/plutus-tx-plugin/test/CallTrace/OtherModule.hs b/plutus-tx-plugin/test/CallTrace/OtherModule.hs index cbd08983a81..87164b4ef70 100644 --- a/plutus-tx-plugin/test/CallTrace/OtherModule.hs +++ b/plutus-tx-plugin/test/CallTrace/OtherModule.hs @@ -1,6 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fexpose-all-unfoldings #-} +{-# OPTIONS_GHC -fplugin Plinth.Plugin #-} + +-- It is necessary to have Plinth plugin enabled here so that anchors get correctly added. +-- If Plinth plugin is not enabled, profile-all will not be able to correctly retrieve +-- srcspan and in the call trace function call in this module will not have any srcspan +-- information. module CallTrace.OtherModule where @@ -9,13 +15,9 @@ import PlutusTx.Prelude errorWhenTrue :: Bool -> BuiltinString errorWhenTrue True = error () errorWhenTrue False = "hi" --- NOINLINE ensures that the function appear in the call trace. -{-# NOINLINE errorWhenTrue #-} wraps :: Bool -> BuiltinString wraps = errorWhenTrue --- NOINLINE ensures that the function appear in the call trace. -{-# NOINLINE wraps #-} class MyClassInOtherModule a where myClassFuncInOtherModule :: a -> BuiltinString diff --git a/plutus-tx-plugin/test/CallTrace/Spec.hs b/plutus-tx-plugin/test/CallTrace/Spec.hs index 50ba0c8eec6..ca47e37dde9 100644 --- a/plutus-tx-plugin/test/CallTrace/Spec.hs +++ b/plutus-tx-plugin/test/CallTrace/Spec.hs @@ -8,7 +8,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} -{-# OPTIONS_GHC -fplugin PlutusTx.Plugin #-} +{-# OPTIONS_GHC -fplugin Plinth.Plugin #-} {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:context-level=0 #-} {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:datatypes=BuiltinCasing #-} {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:max-cse-iterations=0 #-} diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.golden.pir b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.golden.pir index 62194e7eb18..78c0070be59 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.golden.pir +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt.golden.pir @@ -1,5 +1,20 @@ let !addInteger : integer -> integer -> integer = addInteger + ~addInteger : integer -> integer -> integer + = \(x : integer) -> + let + !x : integer = x + in + \(y : integer) -> + let + !y : integer = y + in + trace + {unit -> integer} + "-> addInteger" + (\(thunk : unit) -> + trace {integer} "<- addInteger" (addInteger x y)) + () ~addInt : integer -> integer -> integer = \(x : integer) -> let @@ -7,12 +22,12 @@ let in trace {unit -> integer -> integer} - "-> addInt (test/Plugin/Profiling/Spec.hs:116:1-116:6)" + "-> addInt (test/Plugin/Profiling/Spec.hs:115:1-115:6)" (\(thunk : unit) -> trace {integer -> integer} - "<- addInt (test/Plugin/Profiling/Spec.hs:116:1-116:6)" - (\(y : integer) -> let !y : integer = y in addInteger x y)) + "<- addInt (test/Plugin/Profiling/Spec.hs:115:1-115:6)" + (addInteger x)) () in addInt \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.golden.eval index 60f6f09a3a4..b6c02aff7fb 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/addInt3.golden.eval @@ -1,2 +1,2 @@ -[ -> addInt (test/Plugin/Profiling/Spec.hs:116:1-116:6) -, <- addInt (test/Plugin/Profiling/Spec.hs:116:1-116:6) ] \ No newline at end of file +[ -> addInt (test/Plugin/Profiling/Spec.hs:115:1-115:6) +, <- addInt (test/Plugin/Profiling/Spec.hs:115:1-115:6) ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.golden.eval index a0d442b769e..7ee68870d91 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch1.golden.eval @@ -1,6 +1,6 @@ [ -> runIdentity , <- runIdentity -, -> newtypeFunction (test/Plugin/Profiling/Spec.hs:176:1-176:15) -, <- newtypeFunction (test/Plugin/Profiling/Spec.hs:176:1-176:15) +, -> newtypeFunction (test/Plugin/Profiling/Spec.hs:175:1-175:15) +, <- newtypeFunction (test/Plugin/Profiling/Spec.hs:175:1-175:15) , -> $fFoldableIdentity2 , <- $fFoldableIdentity2 ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.golden.eval index 94cc565a663..f59fd8e0c03 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/argMismatch2.golden.eval @@ -1,2 +1,2 @@ -[ -> obscuredFunction (test/Plugin/Profiling/Spec.hs:184:1-184:16) -, <- obscuredFunction (test/Plugin/Profiling/Spec.hs:184:1-184:16) ] \ No newline at end of file +[ -> obscuredFunction (test/Plugin/Profiling/Spec.hs:183:1-183:16) +, <- obscuredFunction (test/Plugin/Profiling/Spec.hs:183:1-183:16) ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.golden.eval index 4255459576d..de6db16c9d4 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fact4.golden.eval @@ -1,10 +1,36 @@ -[ -> fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, -> fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, -> fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, -> fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, -> fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, <- fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, <- fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, <- fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, <- fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) -, <- fact (test/Plugin/Profiling/Spec.hs:91:1-91:4) ] \ No newline at end of file +[ -> fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> equalsInteger +, <- equalsInteger +, -> subtractInteger +, <- subtractInteger +, -> fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> equalsInteger +, <- equalsInteger +, -> subtractInteger +, <- subtractInteger +, -> fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> equalsInteger +, <- equalsInteger +, -> subtractInteger +, <- subtractInteger +, -> fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> equalsInteger +, <- equalsInteger +, -> subtractInteger +, <- subtractInteger +, -> fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> equalsInteger +, <- equalsInteger +, <- fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> multiplyInteger +, <- multiplyInteger +, <- fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> multiplyInteger +, <- multiplyInteger +, <- fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> multiplyInteger +, <- multiplyInteger +, <- fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) +, -> multiplyInteger +, <- multiplyInteger +, <- fact (test/Plugin/Profiling/Spec.hs:90:1-90:4) ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.golden.pir b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.golden.pir index d7a67e7bb4d..ca15b6335bb 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.golden.pir +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib.golden.pir @@ -1,7 +1,52 @@ let !addInteger : integer -> integer -> integer = addInteger + ~addInteger : integer -> integer -> integer + = \(x : integer) -> + let + !x : integer = x + in + \(y : integer) -> + let + !y : integer = y + in + trace + {unit -> integer} + "-> addInteger" + (\(thunk : unit) -> + trace {integer} "<- addInteger" (addInteger x y)) + () !equalsInteger : integer -> integer -> bool = equalsInteger + ~equalsInteger : integer -> integer -> bool + = \(x : integer) -> + let + !x : integer = x + in + \(y : integer) -> + let + !y : integer = y + in + trace + {unit -> bool} + "-> equalsInteger" + (\(thunk : unit) -> + trace {bool} "<- equalsInteger" (equalsInteger x y)) + () !subtractInteger : integer -> integer -> integer = subtractInteger + ~subtractInteger : integer -> integer -> integer + = \(x : integer) -> + let + !x : integer = x + in + \(y : integer) -> + let + !y : integer = y + in + trace + {unit -> integer} + "-> subtractInteger" + (\(thunk : unit) -> + trace {integer} "<- subtractInteger" (subtractInteger x y)) + () in letrec ~fib : integer -> integer @@ -11,11 +56,11 @@ letrec in trace {unit -> integer} - "-> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3)" + "-> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3)" (\(thunk : unit) -> trace {integer} - "<- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3)" + "<- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3)" (case (all dead. integer) (equalsInteger n 0) @@ -24,11 +69,9 @@ letrec (all dead. integer) (equalsInteger n 1) [ (/\dead -> - let - !x : integer = fib (subtractInteger n 1) - !y : integer = fib (subtractInteger n 2) - in - addInteger x y) + addInteger + (fib (subtractInteger n 1)) + (fib (subtractInteger n 2))) , (/\dead -> 1) ] {all dead. dead}) , (/\dead -> 0) ] diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.golden.eval index 7369a825357..9452e19e631 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/fib4.golden.eval @@ -1,18 +1,74 @@ -[ -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, -> fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) -, <- fib (test/Plugin/Profiling/Spec.hs:100:1-100:3) ] \ No newline at end of file +[ -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, -> equalsInteger +, <- equalsInteger +, -> subtractInteger +, <- subtractInteger +, -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, -> equalsInteger +, <- equalsInteger +, -> subtractInteger +, <- subtractInteger +, -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, -> equalsInteger +, <- equalsInteger +, -> subtractInteger +, <- subtractInteger +, -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, -> equalsInteger +, <- equalsInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> subtractInteger +, <- subtractInteger +, -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> addInteger +, <- addInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> subtractInteger +, <- subtractInteger +, -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, -> equalsInteger +, <- equalsInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> addInteger +, <- addInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> subtractInteger +, <- subtractInteger +, -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, -> equalsInteger +, <- equalsInteger +, -> subtractInteger +, <- subtractInteger +, -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, -> equalsInteger +, <- equalsInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> subtractInteger +, <- subtractInteger +, -> fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> equalsInteger +, <- equalsInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> addInteger +, <- addInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) +, -> addInteger +, <- addInteger +, <- fib (test/Plugin/Profiling/Spec.hs:99:1-99:3) ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.golden.eval index 2a7d2d15085..ad494b66cf3 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFun.golden.eval @@ -1,10 +1,10 @@ -[ -> f (test/Plugin/Profiling/Spec.hs:125:9-125:9) +[ -> f (test/Plugin/Profiling/Spec.hs:124:9-124:9) , -> addInteger , <- addInteger -, <- f (test/Plugin/Profiling/Spec.hs:125:9-125:9) -, -> f (test/Plugin/Profiling/Spec.hs:125:9-125:9) +, <- f (test/Plugin/Profiling/Spec.hs:124:9-124:9) +, -> f (test/Plugin/Profiling/Spec.hs:124:9-124:9) , -> addInteger , <- addInteger -, <- f (test/Plugin/Profiling/Spec.hs:125:9-125:9) +, <- f (test/Plugin/Profiling/Spec.hs:124:9-124:9) , -> addInteger , <- addInteger ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.golden.eval index 1e1c04da2fd..c3d0bbb6ec2 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letInFunMoreArg.golden.eval @@ -1,11 +1,11 @@ -[ -> f (test/Plugin/Profiling/Spec.hs:131:9-131:9) +[ -> f (test/Plugin/Profiling/Spec.hs:130:9-130:9) , -> addInteger , <- addInteger -, <- f (test/Plugin/Profiling/Spec.hs:131:9-131:9) -, -> f (test/Plugin/Profiling/Spec.hs:131:9-131:9) +, <- f (test/Plugin/Profiling/Spec.hs:130:9-130:9) +, -> f (test/Plugin/Profiling/Spec.hs:130:9-130:9) , -> addInteger , <- addInteger -, <- f (test/Plugin/Profiling/Spec.hs:131:9-131:9) +, <- f (test/Plugin/Profiling/Spec.hs:130:9-130:9) , -> addInteger , <- addInteger , -> multiplyInteger diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.golden.eval index 84a4206d18c..e03a128a392 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/letRecInFun.golden.eval @@ -1,28 +1,28 @@ -[ -> f (test/Plugin/Profiling/Spec.hs:138:9-138:9) +[ -> f (test/Plugin/Profiling/Spec.hs:137:9-137:9) , -> equalsInteger , <- equalsInteger , -> subtractInteger , <- subtractInteger -, -> f (test/Plugin/Profiling/Spec.hs:138:9-138:9) +, -> f (test/Plugin/Profiling/Spec.hs:137:9-137:9) , -> equalsInteger , <- equalsInteger , -> subtractInteger , <- subtractInteger -, -> f (test/Plugin/Profiling/Spec.hs:138:9-138:9) +, -> f (test/Plugin/Profiling/Spec.hs:137:9-137:9) , -> equalsInteger , <- equalsInteger , -> subtractInteger , <- subtractInteger -, -> f (test/Plugin/Profiling/Spec.hs:138:9-138:9) +, -> f (test/Plugin/Profiling/Spec.hs:137:9-137:9) , -> equalsInteger , <- equalsInteger -, <- f (test/Plugin/Profiling/Spec.hs:138:9-138:9) +, <- f (test/Plugin/Profiling/Spec.hs:137:9-137:9) , -> addInteger , <- addInteger -, <- f (test/Plugin/Profiling/Spec.hs:138:9-138:9) +, <- f (test/Plugin/Profiling/Spec.hs:137:9-137:9) , -> addInteger , <- addInteger -, <- f (test/Plugin/Profiling/Spec.hs:138:9-138:9) +, <- f (test/Plugin/Profiling/Spec.hs:137:9-137:9) , -> addInteger , <- addInteger -, <- f (test/Plugin/Profiling/Spec.hs:138:9-138:9) ] \ No newline at end of file +, <- f (test/Plugin/Profiling/Spec.hs:137:9-137:9) ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.golden.eval index ab8eb8ee6c9..a5b5b6c7b68 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/swap.golden.eval @@ -1,2 +1,2 @@ -[ -> swap (test/Plugin/Profiling/Spec.hs:149:1-149:4) -, <- swap (test/Plugin/Profiling/Spec.hs:149:1-149:4) ] \ No newline at end of file +[ -> swap (test/Plugin/Profiling/Spec.hs:148:1-148:4) +, <- swap (test/Plugin/Profiling/Spec.hs:148:1-148:4) ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.golden.eval b/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.golden.eval index 099818c1c74..932b0926ef8 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.golden.eval +++ b/plutus-tx-plugin/test/Plugin/Profiling/9.6/typeclass.golden.eval @@ -1,10 +1,16 @@ -[ -> useTypeclass (test/Plugin/Profiling/Spec.hs:168:1-168:12) -, -> methodA (test/Plugin/Profiling/Spec.hs:157:3-157:30) -, <- methodA (test/Plugin/Profiling/Spec.hs:157:3-157:30) +[ -> $cmethodA (test/Plugin/Profiling/Spec.hs:161:3-161:9) +, <- $cmethodA (test/Plugin/Profiling/Spec.hs:161:3-161:9) +, -> $cmethodB (test/Plugin/Profiling/Spec.hs:163:3-163:9) +, <- $cmethodB (test/Plugin/Profiling/Spec.hs:163:3-163:9) +, -> useTypeclass (test/Plugin/Profiling/Spec.hs:167:1-167:12) +, -> methodA +, <- methodA , -> addInteger , <- addInteger -, -> methodB (test/Plugin/Profiling/Spec.hs:158:3-158:30) -, <- methodB (test/Plugin/Profiling/Spec.hs:158:3-158:30) +, -> methodB +, <- methodB , -> subtractInteger , <- subtractInteger -, <- useTypeclass (test/Plugin/Profiling/Spec.hs:168:1-168:12) ] \ No newline at end of file +, -> addInteger +, <- addInteger +, <- useTypeclass (test/Plugin/Profiling/Spec.hs:167:1-167:12) ] \ No newline at end of file diff --git a/plutus-tx-plugin/test/Plugin/Profiling/Spec.hs b/plutus-tx-plugin/test/Plugin/Profiling/Spec.hs index 5a700c115eb..eb38a024f78 100644 --- a/plutus-tx-plugin/test/Plugin/Profiling/Spec.hs +++ b/plutus-tx-plugin/test/Plugin/Profiling/Spec.hs @@ -5,14 +5,14 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} -{-# OPTIONS_GHC -fplugin PlutusTx.Plugin #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:context-level=3 #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:datatypes=BuiltinCasing #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:max-cse-iterations=0 #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:max-simplifier-iterations-pir=0 #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:max-simplifier-iterations-uplc=0 #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:profile-all #-} +{-# OPTIONS_GHC -fplugin Plinth.Plugin #-} +{-# OPTIONS_GHC -fplugin-opt Plinth.Plugin:context-level=3 #-} +{-# OPTIONS_GHC -fplugin-opt Plinth.Plugin:datatypes=BuiltinCasing #-} +{-# OPTIONS_GHC -fplugin-opt Plinth.Plugin:defer-errors #-} +{-# OPTIONS_GHC -fplugin-opt Plinth.Plugin:max-cse-iterations=0 #-} +{-# OPTIONS_GHC -fplugin-opt Plinth.Plugin:max-simplifier-iterations-pir=0 #-} +{-# OPTIONS_GHC -fplugin-opt Plinth.Plugin:max-simplifier-iterations-uplc=0 #-} +{-# OPTIONS_GHC -fplugin-opt Plinth.Plugin:profile-all #-} {-# HLINT ignore "Eta reduce" #-} {-# HLINT ignore "Use guards" #-} @@ -25,14 +25,13 @@ module Plugin.Profiling.Spec where import Test.Tasty.Extras +import Plinth.Plugin (plinthc) import PlutusCore.Test (ToUPlc (toUPlc), goldenUEvalLogs) import PlutusTx.Builtins qualified as Builtins import PlutusTx.Code (CompiledCode) -import PlutusTx.Plugin (plc) import PlutusTx.Test (goldenPirReadable) import Data.Functor.Identity -import Data.Proxy (Proxy (Proxy)) import Prelude profiling :: TestNested @@ -43,36 +42,36 @@ profiling = , goldenUEvalLogs "fib4" [ toUPlc fibTest - , toUPlc $ plc (Proxy @"4") (4 :: Integer) + , toUPlc $ plinthc (4 :: Integer) ] , goldenUEvalLogs "fact4" [ toUPlc factTest - , toUPlc $ plc (Proxy @"4") (4 :: Integer) + , toUPlc $ plinthc (4 :: Integer) ] , goldenPirReadable "addInt" addIntTest , goldenUEvalLogs "addInt3" [ toUPlc addIntTest - , toUPlc $ plc (Proxy @"3") (3 :: Integer) + , toUPlc $ plinthc (3 :: Integer) ] , goldenUEvalLogs "letInFun" [ toUPlc letInFunTest - , toUPlc $ plc (Proxy @"1") (1 :: Integer) - , toUPlc $ plc (Proxy @"4") (4 :: Integer) + , toUPlc $ plinthc (1 :: Integer) + , toUPlc $ plinthc (4 :: Integer) ] , goldenUEvalLogs "letInFunMoreArg" [ toUPlc letInFunMoreArgTest - , toUPlc $ plc (Proxy @"1") (1 :: Integer) - , toUPlc $ plc (Proxy @"4") (4 :: Integer) - , toUPlc $ plc (Proxy @"5") (5 :: Integer) + , toUPlc $ plinthc (1 :: Integer) + , toUPlc $ plinthc (4 :: Integer) + , toUPlc $ plinthc (5 :: Integer) ] , goldenUEvalLogs "letRecInFun" [ toUPlc letRecInFunTest - , toUPlc $ plc (Proxy @"3") (3 :: Integer) + , toUPlc $ plinthc (3 :: Integer) ] , goldenPirReadable "idCode" idTest , goldenUEvalLogs "id" [toUPlc idTest] @@ -80,8 +79,8 @@ profiling = , goldenUEvalLogs "typeclass" [ toUPlc typeclassTest - , toUPlc $ plc (Proxy @"1") (1 :: Integer) - , toUPlc $ plc (Proxy @"4") (4 :: Integer) + , toUPlc $ plinthc (1 :: Integer) + , toUPlc $ plinthc (4 :: Integer) ] , goldenUEvalLogs "argMismatch1" [toUPlc argMismatch1] , goldenUEvalLogs "argMismatch2" [toUPlc argMismatch2] @@ -94,7 +93,7 @@ fact n = else Builtins.multiplyInteger n (fact (Builtins.subtractInteger n 1)) factTest :: CompiledCode (Integer -> Integer) -factTest = plc (Proxy @"fact") fact +factTest = plinthc fact fib :: Integer -> Integer fib n = @@ -110,30 +109,30 @@ fib n = fibTest :: CompiledCode (Integer -> Integer) -- not using case to avoid literal cases -fibTest = plc (Proxy @"fib") fib +fibTest = plinthc fib addInt :: Integer -> Integer -> Integer addInt x = Builtins.addInteger x addIntTest :: CompiledCode (Integer -> Integer -> Integer) -addIntTest = plc (Proxy @"addInt") addInt +addIntTest = plinthc addInt -- \x y -> let f z = z + 1 in f x + f y letInFunTest :: CompiledCode (Integer -> Integer -> Integer) -letInFunTest = plc (Proxy @"letInFun") do +letInFunTest = plinthc do \(x :: Integer) (y :: Integer) -> let f z = Builtins.addInteger z 1 in Builtins.addInteger (f x) (f y) -- \x y z -> let f n = n + 1 in z * (f x + f y) letInFunMoreArgTest :: CompiledCode (Integer -> Integer -> Integer -> Integer) -letInFunMoreArgTest = plc (Proxy @"letInFun") do +letInFunMoreArgTest = plinthc do \(x :: Integer) (y :: Integer) (z :: Integer) -> let f n = Builtins.addInteger n 1 in Builtins.multiplyInteger z (Builtins.addInteger (f x) (f y)) -- Try a recursive function so it definitely won't be inlined letRecInFunTest :: CompiledCode (Integer -> Integer) -letRecInFunTest = plc (Proxy @"letRecInFun") do +letRecInFunTest = plinthc do \(x :: Integer) -> let f n = if Builtins.equalsInteger n 0 @@ -142,14 +141,14 @@ letRecInFunTest = plc (Proxy @"letRecInFun") do in f x idTest :: CompiledCode Integer -idTest = plc (Proxy @"id") do +idTest = plinthc do id (id (1 :: Integer)) swap :: (a, b) -> (b, a) swap (a, b) = (b, a) swapTest :: CompiledCode (Integer, Bool) -swapTest = plc (Proxy @"swap") (swap (True, 1)) +swapTest = plinthc (swap (True, 1)) -- Two method typeclasses definitely get dictionaries, -- rather than just being passed as single functions @@ -169,7 +168,7 @@ useTypeclass a b = Builtins.addInteger (methodA a b) (methodB a b) -- Check that typeclass methods get traces typeclassTest :: CompiledCode (Integer -> Integer -> Integer) -typeclassTest = plc (Proxy @"typeclass") do +typeclassTest = plinthc do \(x :: Integer) (y :: Integer) -> useTypeclass x y newtypeFunction :: a -> Identity (a -> a) @@ -177,7 +176,7 @@ newtypeFunction _ = Identity (\a -> a) {-# INLINEABLE newtypeFunction #-} argMismatch1 :: CompiledCode Integer -argMismatch1 = plc (Proxy @"argMismatch1") do +argMismatch1 = plinthc do runIdentity (newtypeFunction 1) 1 obscuredFunction :: (a -> a -> a) -> a -> a -> a @@ -185,5 +184,5 @@ obscuredFunction f a = f a {-# INLINEABLE obscuredFunction #-} argMismatch2 :: CompiledCode Integer -argMismatch2 = plc (Proxy @"argMismatch2") do +argMismatch2 = plinthc do obscuredFunction (\a _ -> a) 1 2