Skip to content

Implement for fast DFA engine, value tracking and uninitialized memory preventing of reading.#22400

Merged
thewilsonator merged 1 commit intodlang:masterfrom
rikkimax:fastdfa-valuetracking
Feb 22, 2026
Merged

Implement for fast DFA engine, value tracking and uninitialized memory preventing of reading.#22400
thewilsonator merged 1 commit intodlang:masterfrom
rikkimax:fastdfa-valuetracking

Conversation

@rikkimax
Copy link
Copy Markdown
Contributor

@rikkimax rikkimax commented Jan 15, 2026

This PR is to see if there are any failures in the CI beyond what I already know.

EDIT: I've had to change if statements location for assignments, so that it reflects the condition, not the if statement.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @rikkimax! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#22400"

@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch 8 times, most recently from 6efad3b to 4a22be6 Compare January 21, 2026 17:03
@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch 3 times, most recently from 6e06af9 to cde8a54 Compare January 27, 2026 16:40
}

int v = *ret; // ideally would error, but not required
int v = *ret; // no error, cannot know state of ret
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

I don't do truthiness interprocedurally, it's intentional.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm pretty sure it's nothing to do with detecting truthiness, and more to do with representing variables as PHI nodes for each diverging path taken to reach the current point in code.

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.

I'm pretty sure it's nothing to do with detecting truthiness, and more to do with representing variables as PHI nodes for each diverging path taken to reach the current point in code.

https://compiler-explorer.com/z/PqaYojh85

It is modelling truthiness.

@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch from cde8a54 to 3e5de5d Compare January 27, 2026 17:00
@rikkimax
Copy link
Copy Markdown
Contributor Author

I'm looking into the following error:

std/utf.d(2277): Error: Argument is expected to be non-null but was null
        static assert(isSafe!({ S str; size_t i = 0; decode(str, i);      }));
                                                           ^
std/utf.d(1171):        For parameter `str` in argument 0
auto ref scope S str, ref size_t index) @trusted pure
                 ^
std/utf.d(2277):        while evaluating: `static assert(isSafe!(() pure @safe
{
char[] str = null;
ulong i = 0LU;
decode(str, i);
}
))`
        static assert(isSafe!({ S str; size_t i = 0; decode(str, i);      }));
        ^

A quick look over at decode, shows that it does indeed cause a bounds check error if that function were ever be called.

This is another example of where @__ctfe kind of flag would be the solution. Unlike the last time I cannot solve for this.

There are a few more examples of this, relating to decode(front/back), and they appear to all be doing the same thing.
Giving the string a non-empty value, would solve this.

decode is correctly inferring as non-null for its parameter now.

@rikkimax
Copy link
Copy Markdown
Contributor Author

rikkimax commented Jan 28, 2026

I don't know why core.exception.AssertError@std/int128.d(480): unittest failure is happening.

Given that it is a runtime error, not a CT one, I'm inclined that it isn't related.

EDIT: likely is something to do with me, other PR's are green for phobos.

Confirmed its me, toString error'd, and formattedWrite reverted to built in behavior.

testdfa\std\int128.d(445): Error: Expression reads from an uninitialized variable, it must be written to at least once before reading
        const minw = (buf.length - bufStart) + int(signChar != 0);
                                   ^
testdfa\std\int128.d(389):        For variable `bufStart`
        size_t bufStart = void;
               ^
``

@rikkimax
Copy link
Copy Markdown
Contributor Author

boilerplate is a known error, as this is industry code I'm waiting on feep to deal with it.

That covers serialized.

Ocean is known good error.

Okay I'm calling buildkite doing what it is supposed to.

@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch 3 times, most recently from 97e58d5 to a2e9bee Compare February 1, 2026 17:17
@rikkimax
Copy link
Copy Markdown
Contributor Author

rikkimax commented Feb 1, 2026

Lists of tests in testsuite where error is correct:

  • runnable/xtest46_gc.d
  • runnable/xtest46.d
  • runnable/exe1.c
  • runnable/exe2.c
  • runnable/exe3.c
  • runnable/nullderefcheck.d
  • runnable/test12874.d
  • runnable/testassert.d
  • compilable/arraytopointer.c
  • compilable/fix20425.c
  • compilable/interpret3.d
  • compilable/test22755.c
  • compilable/test22842.c
  • compilable/test22875.i
  • compilable/test23044.c
  • compilable/test23875.c
  • compilable/testcomplex.c
  • compilable/testcstuff1.c
  • compilable/testcstuff2.c
  • fail_compilation/failcstuff2.c

Only one known bug: runnable/bitfieldsposix64.c

I also want to fix the failures in phobos for decode somehow.

@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch 9 times, most recently from f946435 to 94defff Compare February 3, 2026 01:15
@rikkimax
Copy link
Copy Markdown
Contributor Author

rikkimax commented Feb 3, 2026

Functionally, it is now complete.

I need to write up a changelog and do an audit, but otherwise its done.

@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch 4 times, most recently from debcdf7 to 8a05725 Compare February 6, 2026 07:10
@rikkimax
Copy link
Copy Markdown
Contributor Author

rikkimax commented Feb 6, 2026

Okay, I'm now happy, but I'll leave it a few days to see if I get annoyed with anything else.

@thewilsonator
Copy link
Copy Markdown
Contributor

Do ping, when this is good to go.

@rikkimax rikkimax changed the title [DO NOT MERGE] Implement for fast DFA engine, value tracking and uninitialized memory preventing of reading. Implement for fast DFA engine, value tracking and uninitialized memory preventing of reading. Feb 11, 2026
@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch from 8a05725 to 796672e Compare February 11, 2026 02:08
@rikkimax rikkimax marked this pull request as ready for review February 11, 2026 02:09
@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch from 796672e to 06fc770 Compare February 11, 2026 02:14
@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch from 06fc770 to 582f163 Compare February 18, 2026 12:15
@rikkimax
Copy link
Copy Markdown
Contributor Author

@thewilsonator

Copy link
Copy Markdown
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

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

Apart from one suspect change looks OK to me.

Comment thread compiler/src/dmd/backend/x86/cod3.d
Comment thread compiler/src/dmd/backend/x86/cod3.d
@rikkimax rikkimax force-pushed the fastdfa-valuetracking branch from 582f163 to 896e5f3 Compare February 21, 2026 15:43
@thewilsonator thewilsonator merged commit 03b0527 into dlang:master Feb 22, 2026
54 of 55 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.

4 participants