Skip to content

Commit

Permalink
Global option --no-check (#3224)
Browse files Browse the repository at this point in the history
The `--no-check` option disables the backend-specific sanity check in
Core (the transformations in `Check/*`, which check the type of main,
use of builtins, etc). This is useful for debugging.
  • Loading branch information
lukaszcz authored Dec 4, 2024
1 parent c79f5e3 commit 70cbdd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/GlobalOptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ data GlobalOptions = GlobalOptions
_globalNoPositivity :: Bool,
_globalNoCoverage :: Bool,
_globalNoStdlib :: Bool,
_globalNoCheck :: Bool,
_globalUnrollLimit :: Int,
_globalNumThreads :: NumThreads,
_globalFieldSize :: Maybe Natural,
Expand Down Expand Up @@ -72,6 +73,7 @@ defaultGlobalOptions =
_globalLogLevel = LogLevelProgress,
_globalNoCoverage = False,
_globalNoStdlib = False,
_globalNoCheck = False,
_globalUnrollLimit = defaultUnrollLimit,
_globalFieldSize = Nothing,
_globalDevShowThreadIds = False,
Expand Down Expand Up @@ -162,6 +164,11 @@ parseGlobalFlags = do
<> intercalate " < " [show l | l <- allElements @LogLevel]
)
)
_globalNoCheck <-
switch
( long "dev-no-check"
<> help "[DEV] Disable input sanity check in Core"
)
_globalShowNameIds <-
switch
( long "show-name-ids"
Expand Down Expand Up @@ -211,6 +218,7 @@ entryPointFromGlobalOptions root mainFile opts = do
_entryPointNoPositivity = opts ^. globalNoPositivity,
_entryPointNoCoverage = opts ^. globalNoCoverage,
_entryPointNoStdlib = opts ^. globalNoStdlib,
_entryPointNoCheck = opts ^. globalNoCheck,
_entryPointUnrollLimit = opts ^. globalUnrollLimit,
_entryPointGenericOptions = project opts,
_entryPointBuildDir = maybe (def ^. entryPointBuildDir) (CustomBuildDir . Abs) mabsBuildDir,
Expand All @@ -232,6 +240,7 @@ entryPointFromGlobalOptionsNoFile root opts = do
_entryPointNoPositivity = opts ^. globalNoPositivity,
_entryPointNoCoverage = opts ^. globalNoCoverage,
_entryPointNoStdlib = opts ^. globalNoStdlib,
_entryPointNoCheck = opts ^. globalNoCheck,
_entryPointUnrollLimit = opts ^. globalUnrollLimit,
_entryPointGenericOptions = project opts,
_entryPointBuildDir = maybe (def ^. entryPointBuildDir) (CustomBuildDir . Abs) mabsBuildDir,
Expand Down
8 changes: 6 additions & 2 deletions src/Juvix/Compiler/Core/Pipeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ where
import Juvix.Compiler.Core.Data.InfoTable
import Juvix.Compiler.Core.Options
import Juvix.Compiler.Core.Transformation
import Juvix.Compiler.Pipeline.EntryPoint (EntryPoint)
import Juvix.Compiler.Pipeline.EntryPoint (EntryPoint, entryPointNoCheck)

toTypechecked :: (Members '[Error JuvixError, Reader EntryPoint] r) => Module -> Sem r Module
toTypechecked = mapReader fromEntryPoint . applyTransformations toTypecheckTransformations
Expand All @@ -19,7 +19,11 @@ toStored = mapReader fromEntryPoint . applyTransformations toStoredTransformatio
-- | Perform transformations on stored Core necessary before the translation to
-- Core.Stripped
toStripped :: (Members '[Error JuvixError, Reader EntryPoint] r) => TransformationId -> Module -> Sem r Module
toStripped checkId = mapReader fromEntryPoint . applyTransformations (toStrippedTransformations checkId)
toStripped checkId md = do
noCheck <- asks (^. entryPointNoCheck)
let checkId' = if noCheck then IdentityTrans else checkId
mapReader fromEntryPoint $
applyTransformations (toStrippedTransformations checkId') md

-- | Perform transformations on stored Core necessary before the translation to VampIR
toVampIR :: (Members '[Error JuvixError, Reader EntryPoint] r) => Module -> Sem r Module
Expand Down
3 changes: 3 additions & 0 deletions src/Juvix/Compiler/Pipeline/EntryPoint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ data EntryPoint = EntryPoint
_entryPointTarget :: Maybe Target,
_entryPointDebug :: Bool,
_entryPointUnsafe :: Bool,
-- | Skip the correctness check in the Core pipeline part.
_entryPointNoCheck :: Bool,
_entryPointUnrollLimit :: Int,
_entryPointOptimizationLevel :: Int,
_entryPointInliningDepth :: Int,
Expand Down Expand Up @@ -76,6 +78,7 @@ defaultEntryPointNoFile pkg root =
_entryPointTarget = Nothing,
_entryPointDebug = False,
_entryPointUnsafe = False,
_entryPointNoCheck = False,
_entryPointUnrollLimit = defaultUnrollLimit,
_entryPointOptimizationLevel = defaultOptimizationLevel,
_entryPointInliningDepth = defaultInliningDepth,
Expand Down

0 comments on commit 70cbdd0

Please sign in to comment.