Uncalled functions in hello world

Stefan Koch uplink.coder at googlemail.com
Wed Apr 8 13:57:47 UTC 2020


The current phobos hello world
import std.stdio;
void main() { "Hello World".writeln; }
generates a list of 36 functions which are generated and emitted 
but not called, and therefore presumably only used at compile time

Those are:

std.typecons.__lambda252|/usr/include/dmd/phobos/std/typecons.d(7277)
std.stdio.File.ByChunkImpl.~this|/usr/include/dmd/phobos/std/stdio.d(2615)
std.stdio.File.ByChunkImpl.__fieldPostblit|/usr/include/dmd/phobos/std/stdio.d(2615)
std.typecons.Ternary.make|/usr/include/dmd/phobos/std/typecons.d(9034)
std.stdio.File.LockingTextWriter.~this|/usr/include/dmd/phobos/std/stdio.d(2861)
std.traits.DynamicArrayTypeOf(T)|/usr/include/dmd/phobos/std/traits.d(5791)
std.range.primitives.empty!(const(char)[]).empty|/usr/include/dmd/phobos/std/range/primitives.d(2184)
std.range.primitives.isInputRange(R)|/usr/include/dmd/phobos/std/range/primitives.d(173)
std.range.primitives.isInputRange(R)|/usr/include/dmd/phobos/std/range/primitives.d(174)
std.range.primitives.isInputRange(R)|/usr/include/dmd/phobos/std/range/primitives.d(175)
object.__equals!(immutable(char), 
immutable(char)).__equals.__lambda3|/usr/include/dmd/druntime/import/object.d(398)
object.__equals!(immutable(char), 
immutable(char)).__equals.at!(immutable(char)).at|/usr/include/dmd/druntime/import/object.d(358)
object.__equals!(immutable(char), 
immutable(char)).__equals|/usr/include/dmd/druntime/import/object.d(352)
std.functional.safeOp!"<".safeOp!(ulong, 
immutable(ubyte)).safeOp|/usr/include/dmd/phobos/std/functional.d(446)
std.algorithm.comparison.min!(ulong, 
immutable(ubyte)).min|/usr/include/dmd/phobos/std/algorithm/comparison.d(1641)
std.range.primitives.popFront!char.popFront|/usr/include/dmd/phobos/std/range/primitives.d(2254)
std.range.primitives.isInputRange(R)|/usr/include/dmd/phobos/std/range/primitives.d(176)
std.utf.decodeImpl!(true, cast(Flag)false, 
const(char)[]).decodeImpl.exception!(const(char)[]).exception|/usr/include/dmd/phobos/std/utf.d(1491)
std.utf.decodeImpl!(true, cast(Flag)false, 
const(char)[]).decodeImpl.invalidUTF|/usr/include/dmd/phobos/std/utf.d(1505)
std.utf.decodeImpl!(true, cast(Flag)false, 
const(char)[]).decodeImpl.outOfBounds|/usr/include/dmd/phobos/std/utf.d(1522)
std.utf.decodeImpl!(true, cast(Flag)false, 
const(char)[]).decodeImpl|/usr/include/dmd/phobos/std/utf.d(1447)
std.utf.decode!(cast(Flag)false, 
const(char)[]).decode|/usr/include/dmd/phobos/std/utf.d(1127)
std.range.primitives.front!char.front|/usr/include/dmd/phobos/std/range/primitives.d(2454)
std.range.primitives.empty!string.empty|/usr/include/dmd/phobos/std/range/primitives.d(2184)
std.range.primitives.isInputRange(R)|/usr/include/dmd/phobos/std/range/primitives.d(173)
std.range.primitives.isInputRange(R)|/usr/include/dmd/phobos/std/range/primitives.d(174)
std.range.primitives.isInputRange(R)|/usr/include/dmd/phobos/std/range/primitives.d(175)
std.range.primitives.isInputRange(R)|/usr/include/dmd/phobos/std/range/primitives.d(176)
std.range.primitives.isInfinite(R)|/usr/include/dmd/phobos/std/range/primitives.d(1621)
std.exception.enforce!(ErrnoException).enforce!int.enforce.__lambda1|/usr/include/dmd/phobos/std/exception.d(434)
object.idup!(const(char)).idup.__lambda2|/usr/include/dmd/druntime/import/object.d(4578)
object._getPostblit!(immutable(char))._getPostblit.__dgliteral1|/usr/include/dmd/druntime/import/object.d(4652)
std.stdio.File.LockingTextWriter.put!string.put.__dgliteral2|/usr/include/dmd/phobos/std/stdio.d(2899)
std.range.primitives.front!char.front|/usr/include/dmd/phobos/std/range/primitives.d(2454)
object.__equals!(immutable(char), 
immutable(char)).__equals|/usr/include/dmd/druntime/import/object.d(352)

So you can see that there is something to be won even in the most 
trivial examples if we have facilities to disable codegen for 
functions which are only used at compiletime.


More information about the Digitalmars-d mailing list