Describe the feature you'd like
|
maybeProfileRhs |
|
:: CompilingDefault uni fun m ann |
|
=> GHC.Var |
|
-> PLCVar uni |
|
-> PIRTerm uni fun |
|
-> m (PIRTerm uni fun) |
|
maybeProfileRhs ghcVar 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 |
|
Nothing -> nameStr |
|
Just src -> nameStr <> " (" <> show (src ^. srcSpanIso) <> ")" |
|
|
|
ty = PLC._varDeclType var |
|
isFunctionOrAbstraction = case ty of PLC.TyFun {} -> True; PLC.TyForall {} -> True; _ -> False |
|
-- Trace only if profiling is on *and* the thing being defined is a function |
|
if coProfile compileOpts == All && isFunctionOrAbstraction |
|
then do |
|
thunk <- PLC.freshName "thunk" |
|
pure $ entryExitTracingInside thunk displayName t ty |
|
else pure t |
This function is used to insert call profiling information to each function calls which is used to run profiling and also call trace information. Currently, it gets source span from GHC.Var; source span attached to GHC.Var is only available if the module GHC.Var resides in gets compiled from scratch without compilation cache. So, to get accurate source spans for these profiling traces, one must always run cabal clean and if not it will add traces without source span.
It should be possible now to get accurate srcspan without needing cabal clean with #7640
Describe alternatives you've considered
No response
Describe the feature you'd like
plutus/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs
Lines 662 to 687 in a8a5a35
This function is used to insert call profiling information to each function calls which is used to run profiling and also call trace information. Currently, it gets source span from
GHC.Var; source span attached toGHC.Varis only available if the moduleGHC.Varresides in gets compiled from scratch without compilation cache. So, to get accurate source spans for these profiling traces, one must always runcabal cleanand if not it will add traces without source span.It should be possible now to get accurate srcspan without needing
cabal cleanwith #7640Describe alternatives you've considered
No response