Skip to content

Don't lower for codegen in functions that are never code generated - #23942

Merged
thewilsonator merged 1 commit into
dlang:masterfrom
TurkeyMan:pr2_needscodegen_skipcodegen
Sep 29, 2026
Merged

thewilsonator merged 1 commit into
dlang:masterfrom
TurkeyMan:pr2_needscodegen_skipcodegen

Conversation

@TurkeyMan

Copy link
Copy Markdown
Contributor

Scope.needsCodegen() is now false inside a function with skipCodegen, ie; a @__ctfe function, so its new is not lowered to the _d_newclassT hook, which a minimal runtime may not have.

@TurkeyMan
TurkeyMan force-pushed the pr2_needscodegen_skipcodegen branch from 2b02cf1 to f8cdda6 Compare September 29, 2026 13:53
@TurkeyMan

Copy link
Copy Markdown
Contributor Author

This doesn't feel worthy of a changelog entry... it's really trivial.

@@ -0,0 +1,21 @@
/*
DFLAGS:
REQUIRED_ARGS: -conf= -betterC -c -Icompilable/extra-files/ctfe_only_new

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check that without -c this fails compilation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear exactly what you mean; is this what you want to see? Ie, proof that it does not attempt to link _d_newclassT when ctfe new is used?

@TurkeyMan
TurkeyMan force-pushed the pr2_needscodegen_skipcodegen branch from f8cdda6 to ae1cfdf Compare September 29, 2026 14:15
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

DMD perf check

Metric Base PR Δ
compile Phobos codegen (instr) 1,423.6 M 1,427.7 M +0.292%
All measurements
Metric Base PR Δ
compile hello.d (instr) 211.6 M 211.6 M -0.004%
compile hello.d -O -release (instr) 229.2 M 229.1 M -0.006%
compile Phobos (instr) 4,896.1 M 4,900.5 M +0.089%
compile Phobos codegen (instr) 1,423.6 M 1,427.7 M +0.292%
compile vibe.d (instr) 14,468.5 M 14,478.2 M +0.067%
dmd binary size (stripped) 8.12 MB 8.12 MB +0.05%
hello binary size (stripped) 0.72 MB 0.72 MB 0.00%
peak RSS (compile hello.d) 44.25 MB 44.22 MB -0.07%
peak RSS (compile Phobos) 613.5 MB 613.6 MB +0.02%
peak RSS (compile vibe.d) 1902 MB 1901 MB -0.03%
page faults (compile hello.d) 8,933 8,931 -0.02%
page faults (compile Phobos) 153,372 153,373 0.00%
page faults (compile vibe.d) 477,606 476,928 -0.14%
compile dmd itself (wall) 12.5 s 12.5 s -0.01%
compile hello.d (wall) 66.1 ms 63.6 ms -3.81%
compile Phobos (wall) 1,517 ms 1,474 ms -2.88%

c1f8c67 vs merge-base 10adc6c · about these metrics

@TurkeyMan
TurkeyMan force-pushed the pr2_needscodegen_skipcodegen branch from ae1cfdf to 3279777 Compare September 29, 2026 14:33
Scope.needsCodegen() is now false inside a function with skipCodegen set,
e.g. a @__ctfe function, so e.g. its `new` is not lowered to the
_d_newclassT hook, which a minimal runtime may not have.
@TurkeyMan
TurkeyMan force-pushed the pr2_needscodegen_skipcodegen branch from 3279777 to c1f8c67 Compare September 29, 2026 14:36
@thewilsonator
thewilsonator merged commit 13f9b67 into dlang:master Sep 29, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants