remove dead code elimination option (#7669)

This commit is contained in:
Jacek Sieka 2018-04-23 17:02:38 +08:00 • committed by Andreas Rumpf
commit 72dfe176f5
57 changed files with 67 additions and 122 deletions

View file

@ -262,7 +262,8 @@ type
# variable is a thread variable # variable is a thread variable
sfCompileTime, # proc can be evaluated at compile time sfCompileTime, # proc can be evaluated at compile time
sfConstructor, # proc is a C++ constructor sfConstructor, # proc is a C++ constructor
sfDeadCodeElim, # dead code elimination for the module is turned on sfDispatcher, # copied method symbol is the dispatcher
# deprecated and unused, except for the con
sfBorrow, # proc is borrowed sfBorrow, # proc is borrowed
sfInfixCall, # symbol needs infix call syntax in target language; sfInfixCall, # symbol needs infix call syntax in target language;
# for interfacing with C++, JS # for interfacing with C++, JS
@ -275,10 +276,9 @@ type
TSymFlags* = set[TSymFlag] TSymFlags* = set[TSymFlag]
const const
sfDispatcher* = sfDeadCodeElim # copied method symbol is the dispatcher
sfNoInit* = sfMainModule # don't generate code to init the variable sfNoInit* = sfMainModule # don't generate code to init the variable
sfImmediate* = sfDeadCodeElim sfImmediate* = sfDispatcher
# macro or template is immediately expanded # macro or template is immediately expanded
# without considering any possible overloads # without considering any possible overloads
sfAllUntyped* = sfVolatile # macro or template is immediately expanded \ sfAllUntyped* = sfVolatile # macro or template is immediately expanded \

View file

@ -2264,7 +2264,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
of nkEmpty: discard of nkEmpty: discard
of nkWhileStmt: genWhileStmt(p, n) of nkWhileStmt: genWhileStmt(p, n)
of nkVarSection, nkLetSection: genVarStmt(p, n) of nkVarSection, nkLetSection: genVarStmt(p, n)
of nkConstSection: genConstStmt(p, n) of nkConstSection: discard # consts generated lazily on use
of nkForStmt: internalError(n.info, "for statement not eliminated") of nkForStmt: internalError(n.info, "for statement not eliminated")
of nkCaseStmt: genCase(p, n, d) of nkCaseStmt: genCase(p, n, d)
of nkReturnStmt: genReturnStmt(p, n) of nkReturnStmt: genReturnStmt(p, n)
@ -2315,8 +2315,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
# are not transformed correctly. We work around this issue (#411) here # are not transformed correctly. We work around this issue (#411) here
# by ensuring it's no inner proc (owner is a module): # by ensuring it's no inner proc (owner is a module):
if prc.skipGenericOwner.kind == skModule and sfCompileTime notin prc.flags: if prc.skipGenericOwner.kind == skModule and sfCompileTime notin prc.flags:
if (not emitLazily(prc)) or if ({sfExportc, sfCompilerProc} * prc.flags == {sfExportc}) or
({sfExportc, sfCompilerProc} * prc.flags == {sfExportc}) or
(sfExportc in prc.flags and lfExportLib in prc.loc.flags) or (sfExportc in prc.flags and lfExportLib in prc.loc.flags) or
(prc.kind == skMethod): (prc.kind == skMethod):
# we have not only the header: # we have not only the header:

View file

@ -280,20 +280,6 @@ proc genVarStmt(p: BProc, n: PNode) =
else: else:
genVarTuple(p, it) genVarTuple(p, it)
proc genConstStmt(p: BProc, n: PNode) =
for it in n.sons:
if it.kind == nkCommentStmt: continue
if it.kind != nkConstDef: internalError(n.info, "genConstStmt")
let sym = it.sons[0].sym
if sym.typ.containsCompileTimeOnly or
sym.typ.kind notin ConstantDataTypes or
sym.ast.len == 0 or
emitLazily(sym):
continue
requestConstImpl(p, sym)
proc genIf(p: BProc, n: PNode, d: var TLoc) = proc genIf(p: BProc, n: PNode, d: var TLoc) =
# #
# { if (!expr1) goto L1; # { if (!expr1) goto L1;

View file

@ -211,8 +211,4 @@ proc mangle*(name: string): string =
if requiresUnderscore: if requiresUnderscore:
result.add "_" result.add "_"
proc emitLazily*(s: PSym): bool {.inline.} =
result = optDeadCodeElim in gGlobalOptions or
sfDeadCodeElim in getModule(s).flags
initTypeTables() initTypeTables()

View file

@ -1309,10 +1309,6 @@ proc newModule(g: BModuleList; module: PSym): BModule =
growCache g.modules, module.position growCache g.modules, module.position
g.modules[module.position] = result g.modules[module.position] = result
if (optDeadCodeElim in gGlobalOptions):
if (sfDeadCodeElim in module.flags):
internalError("added pending module twice: " & toFilename(FileIndex module.position))
template injectG(config) {.dirty.} = template injectG(config) {.dirty.} =
if graph.backend == nil: if graph.backend == nil:
graph.backend = newModuleList(config) graph.backend = newModuleList(config)

View file

@ -268,7 +268,6 @@ proc testCompileOption*(switch: string, info: TLineInfo): bool =
of "movechecks": result = contains(gOptions, optMoveCheck) of "movechecks": result = contains(gOptions, optMoveCheck)
of "linedir": result = contains(gOptions, optLineDir) of "linedir": result = contains(gOptions, optLineDir)
of "assertions", "a": result = contains(gOptions, optAssert) of "assertions", "a": result = contains(gOptions, optAssert)
of "deadcodeelim": result = contains(gGlobalOptions, optDeadCodeElim)
of "run", "r": result = contains(gGlobalOptions, optRun) of "run", "r": result = contains(gGlobalOptions, optRun)
of "symbolfiles": result = gSymbolFiles != disabledSf of "symbolfiles": result = gSymbolFiles != disabledSf
of "genscript": result = contains(gGlobalOptions, optGenScript) of "genscript": result = contains(gGlobalOptions, optGenScript)
@ -509,7 +508,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "movechecks": processOnOffSwitch({optMoveCheck}, arg, pass, info) of "movechecks": processOnOffSwitch({optMoveCheck}, arg, pass, info)
of "linedir": processOnOffSwitch({optLineDir}, arg, pass, info) of "linedir": processOnOffSwitch({optLineDir}, arg, pass, info)
of "assertions", "a": processOnOffSwitch({optAssert}, arg, pass, info) of "assertions", "a": processOnOffSwitch({optAssert}, arg, pass, info)
of "deadcodeelim": processOnOffSwitchG({optDeadCodeElim}, arg, pass, info) of "deadcodeelim": discard # deprecated, dead code elim always on
of "threads": of "threads":
processOnOffSwitchG({optThreads}, arg, pass, info) processOnOffSwitchG({optThreads}, arg, pass, info)
#if optThreads in gGlobalOptions: incl(gNotes, warnGcUnsafe) #if optThreads in gGlobalOptions: incl(gNotes, warnGcUnsafe)

View file

@ -41,7 +41,8 @@ type # please make sure we have under 32 options
TOptions* = set[TOption] TOptions* = set[TOption]
TGlobalOption* = enum # **keep binary compatible** TGlobalOption* = enum # **keep binary compatible**
gloptNone, optForceFullMake, optDeadCodeElim, gloptNone, optForceFullMake,
optDeadCodeElimUnused, # deprecated, always on
optListCmd, optCompileOnly, optNoLinking, optListCmd, optCompileOnly, optNoLinking,
optCDebug, # turn on debugging information optCDebug, # turn on debugging information
optGenDynLib, # generate a dynamic library optGenDynLib, # generate a dynamic library

View file

@ -44,7 +44,9 @@ const
wWarnings, wHints, wWarnings, wHints,
wLinedir, wStacktrace, wLinetrace, wOptimization, wHint, wWarning, wError, wLinedir, wStacktrace, wLinetrace, wOptimization, wHint, wWarning, wError,
wFatal, wDefine, wUndef, wCompile, wLink, wLinksys, wPure, wPush, wPop, wFatal, wDefine, wUndef, wCompile, wLink, wLinksys, wPure, wPush, wPop,
wBreakpoint, wWatchPoint, wPassl, wPassc, wDeadCodeElim, wDeprecated, wBreakpoint, wWatchPoint, wPassl, wPassc,
wDeadCodeElimUnused, # deprecated, always on
wDeprecated,
wFloatchecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, wFloatchecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll,
wLinearScanEnd, wPatterns, wEffects, wNoForward, wReorder, wComputedGoto, wLinearScanEnd, wPatterns, wEffects, wNoForward, wReorder, wComputedGoto,
wInjectStmt, wDeprecated, wExperimental, wThis} wInjectStmt, wDeprecated, wExperimental, wThis}
@ -215,10 +217,6 @@ proc onOff(c: PContext, n: PNode, op: TOptions) =
if isTurnedOn(c, n): gOptions = gOptions + op if isTurnedOn(c, n): gOptions = gOptions + op
else: gOptions = gOptions - op else: gOptions = gOptions - op
proc pragmaDeadCodeElim(c: PContext, n: PNode) =
if isTurnedOn(c, n): incl(c.module.flags, sfDeadCodeElim)
else: excl(c.module.flags, sfDeadCodeElim)
proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) = proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) =
if isTurnedOn(c, n): incl(c.module.flags, flag) if isTurnedOn(c, n): incl(c.module.flags, flag)
else: excl(c.module.flags, flag) else: excl(c.module.flags, flag)
@ -764,7 +762,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
of wThreadVar: of wThreadVar:
noVal(it) noVal(it)
incl(sym.flags, sfThread) incl(sym.flags, sfThread)
of wDeadCodeElim: pragmaDeadCodeElim(c, it) of wDeadCodeElimUnused: discard # deprecated, dead code elim always on
of wNoForward: pragmaNoForward(c, it) of wNoForward: pragmaNoForward(c, it)
of wReorder: pragmaNoForward(c, it, sfReorder) of wReorder: pragmaNoForward(c, it, sfReorder)
of wMagic: processMagic(c, it, sym) of wMagic: processMagic(c, it, sym)
@ -960,10 +958,6 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
if sym.kind != skType or sym.typ == nil: invalidPragma(it) if sym.kind != skType or sym.typ == nil: invalidPragma(it)
else: else:
incl(sym.typ.flags, tfPartial) incl(sym.typ.flags, tfPartial)
# .partial types can only work with dead code elimination
# to prevent the codegen from doing anything before we compiled
# the whole program:
incl gGlobalOptions, optDeadCodeElim
of wInject, wGensym: of wInject, wGensym:
# We check for errors, but do nothing with these pragmas otherwise # We check for errors, but do nothing with these pragmas otherwise
# as they are handled directly in 'evalTemplate'. # as they are handled directly in 'evalTemplate'.

View file

@ -55,7 +55,8 @@ type
wFloatchecks, wNanChecks, wInfChecks, wMoveChecks, wFloatchecks, wNanChecks, wInfChecks, wMoveChecks,
wAssertions, wPatterns, wWarnings, wAssertions, wPatterns, wWarnings,
wHints, wOptimization, wRaises, wWrites, wReads, wSize, wEffects, wTags, wHints, wOptimization, wRaises, wWrites, wReads, wSize, wEffects, wTags,
wDeadCodeElim, wSafecode, wPackage, wNoForward, wReorder, wNoRewrite, wDeadCodeElimUnused, # deprecated, dead code elim always happens
wSafecode, wPackage, wNoForward, wReorder, wNoRewrite,
wPragma, wPragma,
wCompileTime, wNoInit, wCompileTime, wNoInit,
wPassc, wPassl, wBorrow, wDiscardable, wPassc, wPassl, wBorrow, wDiscardable,
@ -143,7 +144,8 @@ const
"assertions", "patterns", "warnings", "hints", "assertions", "patterns", "warnings", "hints",
"optimization", "raises", "writes", "reads", "size", "effects", "tags", "optimization", "raises", "writes", "reads", "size", "effects", "tags",
"deadcodeelim", "safecode", "package", "noforward", "reorder", "norewrite", "deadcodeelim", # deprecated, dead code elim always happens
"safecode", "package", "noforward", "reorder", "norewrite",
"pragma", "pragma",
"compiletime", "noinit", "compiletime", "noinit",
"passc", "passl", "borrow", "discardable", "fieldchecks", "passc", "passl", "borrow", "discardable", "fieldchecks",

View file

@ -29,7 +29,6 @@ Options:
--nanChecks:on|off turn NaN checks on|off --nanChecks:on|off turn NaN checks on|off
--infChecks:on|off turn Inf checks on|off --infChecks:on|off turn Inf checks on|off
--nilChecks:on|off turn nil checks on|off --nilChecks:on|off turn nil checks on|off
--deadCodeElim:on|off whole program dead code elimination on|off
--opt:none|speed|size optimize not at all or for speed|size --opt:none|speed|size optimize not at all or for speed|size
Note: use -d:release for a release build! Note: use -d:release for a release build!
--debugger:native|endb use native debugger (gdb) | ENDB (experimental) --debugger:native|endb use native debugger (gdb) | ENDB (experimental)

View file

@ -6768,22 +6768,6 @@ the created global variables within a module is not defined, but all of them
will be initialized after any top-level variables in their originating module will be initialized after any top-level variables in their originating module
and before any variable in a module that imports it. and before any variable in a module that imports it.
deadCodeElim pragma
-------------------
The ``deadCodeElim`` pragma only applies to whole modules: It tells the
compiler to activate (or deactivate) dead code elimination for the module the
pragma appears in.
The ``--deadCodeElim:on`` command line switch has the same effect as marking
every module with ``{.deadCodeElim:on}``. However, for some modules such as
the GTK wrapper it makes sense to *always* turn on dead code elimination -
no matter if it is globally active or not.
Example:
.. code-block:: nim
{.deadCodeElim: on.}
.. ..
NoForward pragma NoForward pragma

View file

@ -181,7 +181,7 @@ generated; use the ``--symbolFiles:on`` command line switch to activate them.
Unfortunately due to technical reasons the ``--symbolFiles:on`` needs Unfortunately due to technical reasons the ``--symbolFiles:on`` needs
to *aggregate* some generated C code. This means that the resulting executable to *aggregate* some generated C code. This means that the resulting executable
might contain some cruft even when dead code elimination is turned on. So might contain some cruft even with dead code elimination. So
the final release build should be done with ``--symbolFiles:off``. the final release build should be done with ``--symbolFiles:off``.
Due to the aggregation of C code it is also recommended that each project Due to the aggregation of C code it is also recommended that each project
@ -439,7 +439,7 @@ target.
For example, to generate code for an `AVR`:idx: processor use this command:: For example, to generate code for an `AVR`:idx: processor use this command::
nim c --cpu:avr --os:standalone --deadCodeElim:on --genScript x.nim nim c --cpu:avr --os:standalone --genScript x.nim
For the ``standalone`` target one needs to provide For the ``standalone`` target one needs to provide
a file ``panicoverride.nim``. a file ``panicoverride.nim``.

View file

@ -32,7 +32,7 @@
include "system/inclrtl" include "system/inclrtl"
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
when hostOS == "solaris": when hostOS == "solaris":
{.passl: "-lsocket -lnsl".} {.passl: "-lsocket -lnsl".}

View file

@ -81,7 +81,7 @@
## ##
## theDb.close() ## theDb.close()
{.deadCodeElim:on.} {.deadCodeElim: on.} # dce option deprecated
import strutils, sqlite3 import strutils, sqlite3

View file

@ -13,7 +13,7 @@
## is used. This suffices because Windows' console already provides the ## is used. This suffices because Windows' console already provides the
## wanted functionality. ## wanted functionality.
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
when defined(Windows): when defined(Windows):
proc readLineFromStdin*(prompt: string): TaintedString {. proc readLineFromStdin*(prompt: string): TaintedString {.

View file

@ -7,7 +7,7 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim:on.} {.deadCodeElim: on.} # dce option deprecated
from posix import SocketHandle from posix import SocketHandle

View file

@ -7,7 +7,7 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim:on.} {.deadCodeElim: on.} # dce option deprecated
# Get the platform-dependent flags. # Get the platform-dependent flags.
# Structure describing an inotify event. # Structure describing an inotify event.

View file

@ -7,8 +7,6 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim:on.}
from posix import Timespec from posix import Timespec
when defined(macosx) or defined(freebsd) or defined(openbsd) or when defined(macosx) or defined(freebsd) or defined(openbsd) or

View file

@ -1,4 +1,4 @@
{.deadCodeElim:on.} {.deadCodeElim: on.} # dce option deprecated
import posix import posix

View file

@ -27,10 +27,10 @@
## resulting C code will just ``#include <XYZ.h>`` and *not* define the ## resulting C code will just ``#include <XYZ.h>`` and *not* define the
## symbols declared here. ## symbols declared here.
# This ensures that we don't accidentally generate #includes for files that # Dead code elimination ensures that we don't accidentally generate #includes
# might not exist on a specific platform! The user will get an error only # for files that might not exist on a specific platform! The user will get an
# if they actualy try to use the missing declaration # error only if they actualy try to use the missing declaration
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
# TODO these constants don't seem to be fetched from a header file for unknown # TODO these constants don't seem to be fetched from a header file for unknown
# platforms - where do they come from and why are they here? # platforms - where do they come from and why are they here?

View file

@ -7,7 +7,7 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim:on.} {.deadCodeElim: on.} # dce option deprecated
const const
hasSpawnH = not defined(haiku) # should exist for every Posix system nowadays hasSpawnH = not defined(haiku) # should exist for every Posix system nowadays

View file

@ -7,7 +7,7 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
import posix import posix
type type

View file

@ -10,7 +10,7 @@
## Floating-point environment. Handling of floating-point rounding and ## Floating-point environment. Handling of floating-point rounding and
## exceptions (overflow, division by zero, etc.). ## exceptions (overflow, division by zero, etc.).
{.deadCodeElim:on.} {.deadCodeElim: on.} # dce option deprecated
when defined(Posix) and not defined(haiku): when defined(Posix) and not defined(haiku):
{.passl: "-lm".} {.passl: "-lm".}

View file

@ -12,7 +12,7 @@
## **Warning:** This module is deprecated since version 0.14.0. ## **Warning:** This module is deprecated since version 0.14.0.
{.deprecated.} {.deprecated.}
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
{.push debugger:off .} # the user does not want to trace a part {.push debugger:off .} # the user does not want to trace a part
# of the standard library! # of the standard library!

View file

@ -68,7 +68,7 @@
## ``newSocket()``. The difference is that the latter creates a new file ## ``newSocket()``. The difference is that the latter creates a new file
## descriptor. ## descriptor.
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
import nativesockets, os, strutils, parseutils, times, sets, options import nativesockets, os, strutils, parseutils, times, sets, options
export Port, `$`, `==` export Port, `$`, `==`
export Domain, SockType, Protocol export Domain, SockType, Protocol

View file

@ -10,7 +10,7 @@
## This module contains basic operating system facilities like ## This module contains basic operating system facilities like
## retrieving environment variables, reading command line arguments, ## retrieving environment variables, reading command line arguments,
## working with directories, running shell commands, etc. ## working with directories, running shell commands, etc.
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
{.push debugger: off.} {.push debugger: off.}

View file

@ -11,7 +11,7 @@
## ##
## To unpack raw bytes look at the `streams <streams.html>`_ module. ## To unpack raw bytes look at the `streams <streams.html>`_ module.
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
{.push debugger:off .} # the user does not want to trace a part {.push debugger:off .} # the user does not want to trace a part
# of the standard library! # of the standard library!

View file

@ -19,7 +19,7 @@
include "system/inclrtl" include "system/inclrtl"
import streams import streams
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
{.push debugger:off .} # the user does not want to trace a part {.push debugger:off .} # the user does not want to trace a part
# of the standard library! # of the standard library!

View file

@ -12,7 +12,7 @@
import strutils import strutils
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
proc expandTabs*(s: string, tabSize: int = 8): string {.noSideEffect, proc expandTabs*(s: string, tabSize: int = 8): string {.noSideEffect,
procvar.} = procvar.} =

View file

@ -17,7 +17,7 @@ import parseutils
from math import pow, round, floor, log10 from math import pow, round, floor, log10
from algorithm import reverse from algorithm import reverse
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
{.push debugger:off .} # the user does not want to trace a part {.push debugger:off .} # the user does not want to trace a part
# of the standard library! # of the standard library!

View file

@ -9,7 +9,7 @@
## This module provides support to handle the Unicode UTF-8 encoding. ## This module provides support to handle the Unicode UTF-8 encoding.
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
include "system/inclrtl" include "system/inclrtl"

View file

@ -146,7 +146,7 @@ proc declared*(x: untyped): bool {.magic: "Defined", noSideEffect, compileTime.}
## # missing it. ## # missing it.
when defined(useNimRtl): when defined(useNimRtl):
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
proc definedInScope*(x: untyped): bool {. proc definedInScope*(x: untyped): bool {.
magic: "DefinedInScope", noSideEffect, deprecated, compileTime.} magic: "DefinedInScope", noSideEffect, deprecated, compileTime.}

View file

@ -10,7 +10,7 @@
## This module implements a small wrapper for some needed Win API procedures, ## This module implements a small wrapper for some needed Win API procedures,
## so that the Nim compiler does not depend on the huge Windows module. ## so that the Nim compiler does not depend on the huge Windows module.
{.deadCodeElim:on.} {.deadCodeElim: on.} # dce option deprecated
import dynlib import dynlib

View file

@ -34,7 +34,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# **************************************************************************** # ****************************************************************************
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
when defined(windows): when defined(windows):
const dllname = "iup(|30|27|26|25|24).dll" const dllname = "iup(|30|27|26|25|24).dll"

View file

@ -7,7 +7,7 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
{.push, callconv: cdecl.} {.push, callconv: cdecl.}
when defined(Unix): when defined(Unix):

View file

@ -7,7 +7,7 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
when not defined(ODBCVER): when not defined(ODBCVER):
const const

View file

@ -22,7 +22,7 @@
## ./bin/nim c -d:ssl -p:. -r tests/untestable/tssl.nim ## ./bin/nim c -d:ssl -p:. -r tests/untestable/tssl.nim
## ./bin/nim c -d:ssl -p:. --dynlibOverride:ssl --passL:-lcrypto --passL:-lssl -r tests/untestable/tssl.nim ## ./bin/nim c -d:ssl -p:. --dynlibOverride:ssl --passL:-lcrypto --passL:-lssl -r tests/untestable/tssl.nim
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
const useWinVersion = defined(Windows) or defined(nimdoc) const useWinVersion = defined(Windows) or defined(nimdoc)

View file

@ -7,7 +7,7 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
# The current PCRE version information. # The current PCRE version information.

View file

@ -15,7 +15,7 @@
# connection-protocol. # connection-protocol.
# #
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
when defined(windows): when defined(windows):
const const

View file

@ -7,7 +7,7 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
{.deadCodeElim: on.} {.deadCodeElim: on.} # dce option deprecated
when defined(windows): when defined(windows):
when defined(nimOldDlls): when defined(nimOldDlls):
const Lib = "sqlite3.dll" const Lib = "sqlite3.dll"

View file

@ -4,7 +4,7 @@ type
TOption = enum TOption = enum
optNone, optForceFullMake, optBoehmGC, optRefcGC, optRangeCheck, optNone, optForceFullMake, optBoehmGC, optRefcGC, optRangeCheck,
optBoundsCheck, optOverflowCheck, optNilCheck, optAssert, optLineDir, optBoundsCheck, optOverflowCheck, optNilCheck, optAssert, optLineDir,
optWarns, optHints, optDeadCodeElim, optListCmd, optCompileOnly, optWarns, optHints, optListCmd, optCompileOnly,
optSafeCode, # only allow safe code optSafeCode, # only allow safe code
optStyleCheck, optOptimizeSpeed, optOptimizeSize, optGenDynLib, optStyleCheck, optOptimizeSpeed, optOptimizeSize, optGenDynLib,
optGenGuiApp, optStackTrace optGenGuiApp, optStackTrace

View file

@ -4,8 +4,6 @@ discard """
# bug #2023 # bug #2023
{.deadCodeElim:on.}
type type
Obj = object Obj = object
iter: iterator (): int8 {.closure.} iter: iterator (): int8 {.closure.}

View file

@ -23,7 +23,6 @@ const Lib = "libchipmunk.so.6.1.1"
when defined(MoreNim): when defined(MoreNim):
{.hint: "MoreNim defined; some Chipmunk functions replaced in Nim".} {.hint: "MoreNim defined; some Chipmunk functions replaced in Nim".}
{.deadCodeElim: on.}
from math import sqrt, sin, cos, arctan2 from math import sqrt, sin, cos, arctan2
when defined(CpUseFloat): when defined(CpUseFloat):
{.hint: "CpUseFloat defined; using float32 as float".} {.hint: "CpUseFloat defined; using float32 as float".}

View file

@ -20,7 +20,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
const Lib = "libenet.so.1(|.0.3)" const Lib = "libenet.so.1(|.0.3)"
{.deadCodeElim: on.}
const const
ENET_VERSION_MAJOR* = 1 ENET_VERSION_MAJOR* = 1
ENET_VERSION_MINOR* = 3 ENET_VERSION_MINOR* = 3

View file

@ -1,5 +1,5 @@
import macros import macros
{.deadCodeElim: on.}
#Inline macro.add() to allow for easier nesting #Inline macro.add() to allow for easier nesting
proc und*(a: NimNode; b: NimNode): NimNode {.compileTime.} = proc und*(a: NimNode; b: NimNode): NimNode {.compileTime.} =
a.add(b) a.add(b)

View file

@ -12,7 +12,7 @@ else:
LibS = "libcsfml-system.so.2.0" LibS = "libcsfml-system.so.2.0"
LibW = "libcsfml-window.so.2.0" LibW = "libcsfml-window.so.2.0"
#{.error: "Platform unsupported".} #{.error: "Platform unsupported".}
{.deadCodeElim: on.}
{.pragma: pf, pure, final.} {.pragma: pf, pure, final.}
type type
PClock* = ptr TClock PClock* = ptr TClock

View file

@ -1,5 +1,5 @@
import sfml import sfml
{.deadCodeElim: on.}
let let
Black*: TColor = color(0, 0, 0) Black*: TColor = color(0, 0, 0)
White*: TColor = color(255, 255, 255) White*: TColor = color(255, 255, 255)

View file

@ -1,2 +1 @@
import sfml, math, strutils import sfml, math, strutils
{.deadCodeElim: on.}

View file

@ -5,7 +5,7 @@ import
sg_gui, sg_assets, sound_buffer, enet_client sg_gui, sg_assets, sound_buffer, enet_client
when defined(profiler): when defined(profiler):
import nimprof import nimprof
{.deadCodeElim: on.}
type type
PPlayer* = ref TPlayer PPlayer* = ref TPlayer
TPlayer* = object TPlayer* = object

View file

@ -2,7 +2,7 @@ import
sfml, sfml_colors, sfml, sfml_colors,
input_helpers, sg_packets input_helpers, sg_packets
from strutils import countlines from strutils import countlines
{.deadCodeElim: on.}
type type
PGuiContainer* = ref TGuiContainer PGuiContainer* = ref TGuiContainer
TGuiContainer* = object of TObject TGuiContainer* = object of TObject

View file

@ -1,5 +1,4 @@
debugger = off debugger = off
deadCodeElim = on
path = ".." path = ".."
path = "../genpacket" path = "../genpacket"
path = "../helpers" path = "../helpers"

View file

@ -10,7 +10,7 @@ const
ExeName = "keineschweine" ExeName = "keineschweine"
ServerDefines = "-d:NoSFML -d:NoChipmunk" ServerDefines = "-d:NoSFML -d:NoChipmunk"
TestBuildDefines = "-d:escapeMenuTest -d:debugWeps -d:showFPS -d:moreNim -d:debugKeys -d:foo -d:recordMode --forceBuild" TestBuildDefines = "-d:escapeMenuTest -d:debugWeps -d:showFPS -d:moreNim -d:debugKeys -d:foo -d:recordMode --forceBuild"
ReleaseDefines = "-d:release --deadCodeElim:on" ReleaseDefines = "-d:release"
ReleaseTestDefines = "-d:debugWeps -d:debugKeys --forceBuild" ReleaseTestDefines = "-d:debugWeps -d:debugKeys --forceBuild"
task "testprofile", "..": task "testprofile", "..":

View file

@ -1,3 +1,2 @@
--os:standalone --os:standalone
--deadCodeElim:on
--gc:none --gc:none

View file

@ -9,6 +9,9 @@ proc noret1*(i: int) {.noreturn.} =
proc noret2*(i: int): void {.noreturn.} = proc noret2*(i: int): void {.noreturn.} =
echo i echo i
noret1(1)
noret2(2)
var p {.used.}: proc(i: int): int var p {.used.}: proc(i: int): int
doAssert(not compiles( doAssert(not compiles(
p = proc(i: int): int {.noreturn.} = i # noreturn lambda returns int p = proc(i: int): int {.noreturn.} = i # noreturn lambda returns int

View file

@ -1,6 +1,3 @@
{.deadCodeElim: on.}
proc p1*(x, y: int): int = proc p1*(x, y: int): int =
result = x + y result = x + y

View file

@ -15,7 +15,7 @@ _nim()
return 0 return 0
fi fi
case $prev in case $prev in
--stackTrace|--lineTrace|--threads|-x|--checks|--objChecks|--fieldChecks|--rangeChecks|--boundChecks|--overflowChecks|-a|--assertions|--floatChecks|--nanChecks|--infChecks|--deadCodeElim) --stackTrace|--lineTrace|--threads|-x|--checks|--objChecks|--fieldChecks|--rangeChecks|--boundChecks|--overflowChecks|-a|--assertions|--floatChecks|--nanChecks|--infChecks)
# Options that require on/off # Options that require on/off
[[ "$cur" == "=" ]] && cur="" [[ "$cur" == "=" ]] && cur=""
COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
@ -32,7 +32,7 @@ _nim()
return 0 return 0
;; ;;
*) *)
kw="-r -p= --path= -d= --define= -u= --undef= -f --forceBuild --opt= --app= --stackTrace= --lineTrace= --threads= -x= --checks= --objChecks= --fieldChecks= --rangeChecks= --boundChecks= --overflowChecks= -a= --assertions= --floatChecks= --nanChecks= --infChecks= --deadCodeElim=" kw="-r -p= --path= -d= --define= -u= --undef= -f --forceBuild --opt= --app= --stackTrace= --lineTrace= --threads= -x= --checks= --objChecks= --fieldChecks= --rangeChecks= --boundChecks= --overflowChecks= -a= --assertions= --floatChecks= --nanChecks= --infChecks="
COMPREPLY=( $( compgen -W "${kw}" -- $cur ) ) COMPREPLY=( $( compgen -W "${kw}" -- $cur ) )
_filedir '@(nim)' _filedir '@(nim)'
#$split #$split

View file

@ -60,8 +60,6 @@ _nim() {
'*--infChecks=off[turn Inf checks off]' \ '*--infChecks=off[turn Inf checks off]' \
'*--nilChecks=on[turn nil checks on]' \ '*--nilChecks=on[turn nil checks on]' \
'*--nilChecks=off[turn nil checks off]' \ '*--nilChecks=off[turn nil checks off]' \
'*--deadCodeElim=on[whole program dead code elimination on]' \
'*--deadCodeElim=off[whole program dead code elimination off]' \
'*--opt=none[do not optimize]' \ '*--opt=none[do not optimize]' \
'*--opt=speed[optimize for speed|size - use -d:release for a release build]' \ '*--opt=speed[optimize for speed|size - use -d:release for a release build]' \
'*--opt=size[optimize for size]' \ '*--opt=size[optimize for size]' \